前言
最近有幾個(gè)Eclipse下的項(xiàng)目需要導(dǎo)入到Android Studio中,本想應(yīng)該很簡單的,誰知遇到了一大推的問題,特地在此記錄一下(后續(xù)如果有遇到其他的問題再添加進(jìn)來)。
本博客同步發(fā)布于XueLong的博客
錯(cuò)誤匯總
- 錯(cuò)誤一
Error:Application and test application id cannot be the same: both are 'cn.example.application' for debugAndroidTest
這個(gè)錯(cuò)誤是因?yàn)?code>applicationId和testApplicationId相同。
解決方法:修改項(xiàng)目Module下build.gradle中的testApplicationId,不能和applicationId相同。
- 錯(cuò)誤二
Error: java.lang.RuntimeException: Some file crunching failed, see logs for details
解決方法:這個(gè)錯(cuò)誤經(jīng)過驗(yàn)證發(fā)現(xiàn)是因?yàn)轫?xiàng)目中有些 .9.png 不符合Android Studio的要求,所以只需要重新繪制 .9.png即可。
- 錯(cuò)誤三
Error: NDK integration is deprecated in the current plugin.Consider trying the new experimental plugin.Set "$USE_DEPRECATED_NDK=true" in gradle.properties to continue using the current NDK integration.
解決方法:在項(xiàng)目的根目錄添加gradle.properties文件,并在文件中添加android.useDeprecatedNdk=true
- 錯(cuò)誤四
Error:(97) undefined reference to __android_log_print
解決方法:
Android.mk中增加 LOCAL_LDLIBS := -lm -llog
宏定義
#define LOG_TAG “skylark"
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,
__VA_ARGS__)
還要加 #include <Android/log.h>
注意android.mk 里有一行include $(CLEAR_VARS)
必須把LOCAL_LDLIBS :=-llog放在它后面才有用,否則相當(dāng)于沒寫
- 錯(cuò)誤五
Error while executing 'D:\Software\Android\sdk\ndk-bundle\ndk-build.cmd'
with arguments {
NDK_PROJECT_PATH=null
APP_BUILD_SCRIPT=E:\xxx\build\intermediates\ndk\release\Android.mk APP_PLATFORM=android-21
NDK_OUT=E:\xxx\build\intermediates\ndk\release\obj
NDK_LIBS_OUT=E:\xxx\build\intermediates\ndk\release\lib APP_ABI=all
}
解決方法:
//在有JNI的那個(gè)項(xiàng)目下的build.gradle文件中添加如下代碼
android {
...
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
}
- 錯(cuò)誤六
Manifest merger failed : Attribute application@name value=(cn.example.application.MyApp) from AndroidManifest.xml is also present at [APP:MyProject:unspecified] AndroidManifest.xml value=(cn.example.application.MyApp).
Suggestion: add 'tools:replace="android:name"' to <application> element at AndroidManifest.xml to override.
解決方法:修改AndroidManifest.xml中的<application>標(biāo)簽下的application的name,改為全名稱,也就是包名.類名,并加上tools:replace="android:name"
- 錯(cuò)誤七
E:\AndroidStudioProjects\MyApplication\APP\src\main\java\com\MainActivity.java
Error:(1, 1) 錯(cuò)誤: 非法字符: '\ufeff'
Error:(1, 10) 錯(cuò)誤: 需要class, interface或enum
這個(gè)問題是由于文件編碼的錯(cuò)誤導(dǎo)致的。
解決方法:利用notepad++ 將MainActivity.java的編碼格式改為以UTF-8無BOM格式編碼
寫在最后
以上就是目前遇到的Eclipse項(xiàng)目導(dǎo)入到Android Studio中產(chǎn)生的錯(cuò)誤。后續(xù)如果還有其他問題會將其加入其中。
如果你在參考過程中遇到問題,可以在我的聯(lián)系方式中給我提問。
后面會繼續(xù)介紹,Android的相關(guān)知識,歡迎繼續(xù)關(guān)注我博客的更新。
轉(zhuǎn)載請注明:XueLong的博客 ? Android Studio導(dǎo)入Eclipse項(xiàng)目工程錯(cuò)誤匯總