问题
I am very new on using android studio. I am having one eclipse project having Facebook SDK, Google play service, and some other libs as dependencies of my project. I want to ask how to import that project in studio? I have made gradle file of my project but when i import gradle file in studio Facebook and GCM service error occurs. Please can some body tell me the steps so i can import and run project in studio?
回答1:
Migrating from Eclipse to Android Studio requires that you change the structure of your development projects, move to a new build system, and use a new user interface. Here are some of the key changes you should be aware of as you prepare to migrate to Android Studio:
- Project files
- Manifest settings
- Dependencies
- Test code
- User interface
- Gradle-based build
- systemDeveloper
- tools versioning
At first please read this article Migrating to Android Studio And Demo
Now for your requirement add this in your
build.gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile "com.google.android.gms:play-services:7.5.+"
}
回答2:
I would suggest creating a new blank Android Studio project to set up the directory structure and boilerplate. Most of your traditional Eclipse files would go in the app/ directory. Then You'll need to update your app/build.gradle file with your external dependencies as well as tell gradle to pick up any other jars in your app/lib/ directory, e.g. add:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
compile "com.google.android.gms:play-services:7.5.+"
}
You also might need to make a couple more changes to the gradle file for GCM https://developers.google.com/cloud-messaging/android/client.
来源:https://stackoverflow.com/questions/31823713/how-to-import-eclipse-project-libs-and-dependancy-in-studio-android