首先從Eclipse中導(dǎo)出Gradle文件潭辈,再將項(xiàng)目導(dǎo)入Android Studio中匆背。
1者铜、文件編碼的錯(cuò)誤:
Error:(1, 1) 錯(cuò)誤: 非法字符: \65279
Error:(1, 10) 錯(cuò)誤: 需要class, interface或enum
文件中的編碼有錯(cuò)誤静稻,可以將整個(gè)文件的內(nèi)容先復(fù)制下來(Ctrl+c)脚作,然后從項(xiàng)目中刪除文件葫哗,并建立同名的文件,并將內(nèi)容粘貼過去(Ctrl+v)球涛。
2劣针、刪除Module后,如果出現(xiàn):
Failed to complete Gradle execution. Cause: Already disposed: Module: 'XX'
解決方法:
1亿扁、./gradlew clean
2捺典、Restart Android stduio
3、導(dǎo)入后的文件提示
Android Studio “This file is indented with tabs instead of 4 spaces”
Any of the following will work:
Uncheck the Detect and use existing file indents for editing setting.
解決方法:
Change your default indenting for Java (not just on the general Code Style page). Go to File > Settings > Editor > Code Style > Java. On the Tabs and Indents tab click "Use tab character".
4从祝、Android Studio編譯時(shí)Gradle報(bào)亂碼: “編碼 UTF-8 的不可映射字符”
tasks.withType(Compile) {
options.encoding = "UTF-8"
}
?但是這個(gè)配置在gradle2.0以前是可以生效的襟己,在gradle2.0以后就不能生效了,原因是Compile已經(jīng)被重命名為JavaCompile牍陌。所以在gradle2.0以后需要添加的配置如下:
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
解決注釋亂碼問題:
?右下角utf-8換成GB2312擎浴,選擇reload就可以了
5、對于9-patch圖的錯(cuò)誤:
Error: Process 'command finished with non-zero exit value 42
?使用Android Studio自帶的9-patch圖編輯器毒涧,修改完沒有保存贮预,還是會報(bào)錯(cuò)。
?使用Eclipse的SDK下的tools中的工具修改之后,再拷貝過來就正常了仿吞。
6滑频、對于jpg改成png而被Android Studio識別出來不能通過的,可以設(shè)置忽略這項(xiàng)檢查唤冈,在app的build.gradle中误趴,設(shè)置android:
aaptOptions.cruncherEnabled = false;
aaptOptions.useNewCruncher = false;
7、依賴項(xiàng)目引起的錯(cuò)誤:
Error:(43, 9) Attribute application@icon value=(@drawable/new_app_icon) from AndroidManifest.xml:43:9 is also present at com.github.erizet.signala:signala-longpolling:0.20:7:18 value=(@drawable/ic_launcher)
Suggestion: add 'tools:replace="android:icon"' to <application> element at AndroidManifest.xml:40:5 to override
:OpenBook:processDebugManifest FAILED
Error:Execution failed for task ':OpenBook:processDebugManifest'.
Manifest merger failed with multiple errors, see logs
解決方法:
Solved it by adding to my manifest tag xmlns:tools="http://schemas.android.com/tools"
Then added tools:replace="android:icon,android:theme" to the application tag.
This tells the merger to use my manifest icon and theme and not of other libraries
8务傲、在使用的依賴項(xiàng)目中凉当,如果它的Manifest中也含有
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
?有可能導(dǎo)致程序先啟動該module的Activity。
9售葡、Android Studio上的app打叉:
android studio default activity not found
解決方法:
If you see that error occur after upgrading your IDEA, upgrading Android Studio version, or Generating a new APK, you may need to refresh the IDE's cache.
File -> Invalidate Caches / Restart...
10看杭、Android Studio中的ButterKnife插件無法使用,不顯示提示內(nèi)容:
It seems that jcenter has an invalid ssl.
解決方法:
As workaround try to add this to build.gradle
repositories {
mavenCentral()
jcenter {
url "http://jcenter.bintray.com/"
}
}
11挟伙、Android Studio坑爹問題
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity{
……
}
這里找不到support.v7的包楼雹,
因?yàn)槲掖蜷_了另一個(gè)也引了support.v7包的項(xiàng)目,導(dǎo)致當(dāng)前項(xiàng)目中無法找到尖阔。