2014-09-26 32 views
8

我想編譯一個應用程序利用一個單獨的應用程序作爲依賴項,但是當我從這個庫編譯引用模塊時,我看到幾個「錯誤:包不存在」和「錯誤:無法找到符號類」消息從分級。以下是我的兩個構建文件。當使用單獨的應用程序作爲依賴包時不存在

apply plugin: 'android' 

android { 
    compileSdkVersion 19 
    buildToolsVersion "19.1.0" 

    defaultConfig { 
     minSdkVersion 11 
     targetSdkVersion 19 
    } 

    buildTypes { 
     release { 
      runProguard false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
     } 
    } 

    packagingOptions { 
     exclude 'AndroidManifest.xml' 
     exclude 'resources.arsc' 
     exclude 'classes.dex' 
    } 
} 

dependencies { 
    repositories { 
     mavenCentral() 
    } 
    compile 'com.android.support:support-v4:+' 
    compile 'com.google.code.gson:gson:2.2.2' 
    compile 'com.google.android.gms:play-services:+' 
    compile 'com.actionbarsherlock:actionbarsherlock:[email protected]' 
    compile 'com.android.support:support-v4:+' 
    compile 'com.readystatesoftware.systembartint:systembartint:1.0.3' 
    compile 'se.emilsjolander:stickylistheaders:2.+' 
    compile 'com.googlecode.libphonenumber:libphonenumber:+' 
    compile files('libs/crashlytics.jar') 
    compile files('libs/httpclient-4.2.3.jar') 
    compile files('libs/libphonenumber-5.9.jar') 
    compile files('libs/mobileservices-0.2.0-javadoc.jar') 
    compile files('libs/mobileservices-0.2.0.jar') 
    compile files('libs/stringtotime-1.0.4.jar') 
    compile files('libs/urbanairship-lib-2.0.2.jar') 
    compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abs:+' 
    compile files('libs/FlurryAnalytics-4.0.0.jar') 
    compile 'com.squareup.picasso:picasso:2.3.3' 
    compile project(':wheel') 
} 

相關gradle這個:

apply plugin: 'android' 

android { 
    compileSdkVersion 19 
    buildToolsVersion "19.1.0" 

    defaultConfig { 
     applicationId "kankan.wheel" 
     minSdkVersion 5 
     targetSdkVersion 7 
    } 

    buildTypes { 
     release { 
      runProguard false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 
     } 
    } 

} 

誰能幫助/經歷過嗎? Android Studio不會突出顯示該課程中的任何問題,並且我可以通過ctrl +點擊查看引用的軟件包,這似乎意味着它已正確設置...

謝謝!

回答

5

您不能同時使用com.android.application插件的兩個gradle腳本。更改依賴項目以應用「庫」插件。

如果不這樣做,請將您的依賴項的targetSdkVersion更改爲核心項目的依賴項。

+0

工作很好。非常感謝! – User24231 2014-09-27 17:02:04

+0

@Doge你的意思是'com.android.application'? – 2015-04-17 05:28:23

+0

是的,這是新的插件名稱。當我最初編寫答案時,插件被簡單地命名爲'android' – Doge 2015-04-17 06:38:29

0

嘗試根據依賴gradle-default配置將min和target sdk更改爲11和19。

0

我有一個類似的問題貼here

,但我得到了解決使用@總督的建議, 我轉換的依賴Android的項目庫項目。

謝謝。

+0

但是這個錯誤發生在庫模塊中,而不是應用程序模塊中。那麼爲什麼要把你的android項目轉換成庫? – 2015-04-17 05:34:48

+0

您的鏈接被刪除 – 2017-03-20 16:06:37

1

如果您使用的是Android庫模塊作爲一個依賴(即MYLIB),那麼請確保您app.iml文件,您看向文件的末尾以下行:

<orderEntry type="module" module-name="mylib" exported="" /> 
+0

這是什麼? – 2015-04-17 05:32:57

6

的buildTypes部分不應該在庫build.gradle文件中。

+1

如果可以,我會+100。謝謝。 – Dariush 2017-04-21 11:04:02

+1

你的建議對我有用但是有沒有任何解釋? – 2017-04-26 07:27:03

相關問題