我正在嘗試從Eclipse遷移項(xiàng)目,但是沒(méi)有嘗試過(guò)。在Eclipse中,我有3個(gè)項(xiàng)目(2個(gè)android應(yīng)用程序項(xiàng)目和1個(gè)android庫(kù)項(xiàng)目)。2個(gè)應(yīng)用程序項(xiàng)目取決于庫(kù)項(xiàng)目。當(dāng)我執(zhí)行g(shù)radle導(dǎo)出時(shí),我得到3個(gè)無(wú)效的項(xiàng)目。我愿意對(duì)項(xiàng)目進(jìn)行重組,但尚未找到有關(guān)如何完成此工作的任何文檔。有沒(méi)有辦法使Eclipse導(dǎo)出的3個(gè)項(xiàng)目一起工作?我最好重新組織一下事情,如果可以的話,是否提供有關(guān)如何完成此工作的文檔?更新資料我已將整個(gè)項(xiàng)目上傳到GitHub https://github.com/respectTheCode/android-studio-library-example更新1根據(jù)Padma Kumar的建議,這就是我嘗試過(guò)的方法。創(chuàng)建一個(gè)名為 MyApp點(diǎn)擊File > New Module,選擇Android Library并命名MyLib請(qǐng)點(diǎn)擊 Build > Make Project構(gòu)建因此錯(cuò)誤而失敗Module "MyLib" was fully rebuilt due to project configuration/dependencies changesCompilation completed with 1 error and 0 warnings in 19 sec1 error0 warnings/.../MyApp/MyLib/build/bundles/debug/AndroidManifest.xmlGradle: <manifest> does not have package attribute.然后,我package在清單中添加了一個(gè)屬性<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.mylib" >構(gòu)建后出現(xiàn)此錯(cuò)誤Module "MyApp" was fully rebuilt due to project configuration/dependencies changesCompilation completed with 2 errors and 0 warnings in 13 sec2 errors0 warnings/.../MyApp/MyLib/src/main/java/com/example/mylib/MainActivity.javaGradle: package R does not existGradle: package R does not exist添加依賴(lài)性似乎對(duì)該錯(cuò)誤沒(méi)有任何影響。從上面繼續(xù)請(qǐng)點(diǎn)擊 File > Project Structure > Modules > MyApp-MyApp切換至Dependencies標(biāo)簽頁(yè)點(diǎn)擊+ > Module Dependency選擇MyLib點(diǎn)擊Apply并OK請(qǐng)點(diǎn)擊 Build > Make Project更新2根據(jù)伊桑(Ethan)的建議,這是我們得到的2個(gè)子項(xiàng)目build.gradle似乎具有所有正確的部分,唯一的區(qū)別是在下面是插件行MyApp/build.gradle。buildscript { repositories { maven { url 'http://repo1.maven.org/maven2' } } dependencies { classpath 'com.android.tools.build:gradle:0.4' }}apply plugin: 'android'dependencies { compile files('libs/android-support-v4.jar')}android { compileSdkVersion 17 buildToolsVersion "17.0.0" defaultConfig { minSdkVersion 7 targetSdkVersion 16 }}根項(xiàng)目build.gradle是空的,所以我像這樣添加了兩個(gè)項(xiàng)目dependencies { compile project(":MyLib") compile project(":MyApp")}我現(xiàn)在在構(gòu)建時(shí)出現(xiàn)此錯(cuò)誤Gradle:FAILURE: Build failed with an exception.* Where:Build file '/Users/kevin/GitHub/AppPress/MyApp/build.gradle' line: 2
3 回答

交互式愛(ài)情
TA貢獻(xiàn)1712條經(jīng)驗(yàn) 獲得超3個(gè)贊
這是我為mac用戶提供的解決方案,我認(rèn)為它也適用于window:
首先轉(zhuǎn)到您的Android Studio工具欄
Build> Make Project(當(dāng)您在線時(shí),讓其下載文件),然后
生成>編譯模塊“您的應(yīng)用名稱(chēng)顯示在此處”(仍在線,讓文件
下載并完成),然后
運(yùn)行完成的應(yīng)用程序,它將啟動(dòng)模擬器并對(duì)其進(jìn)行配置,然后運(yùn)行它!
這就對(duì)了!?。】鞓?lè)的編碼家伙!
- 3 回答
- 0 關(guān)注
- 864 瀏覽
添加回答
舉報(bào)
0/150
提交
取消