0

I have done migration of Eclipse project to Android Studio. I have used three module and following jar files as library in My Project.

build.gradle with dependencies:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'
    defaultConfig {
        applicationId "com.xxx.xxxxxxxx"
        minSdkVersion 10
        targetSdkVersion 22
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/notice.txt'
    }
    productFlavors {
    }
}

dependencies {
    compile project(':aFileChooser')
    compile files('libs/aquery.jar')
    compile files('libs/google-api-client-1.10.3-beta.jar')
    compile files('libs/google-api-client-android2-1.10.3-beta.jar')
    compile files('libs/google-http-client-1.10.3-beta.jar')
    compile files('libs/google-http-client-android2-1.10.3-beta.jar')
    compile files('libs/google-oauth-client-1.10.1-beta.jar')
    compile files('libs/httpclient-4.3.3.jar')
    compile files('libs/httpcore-4.3.2.jar')
    compile files('libs/httpmime-4.3.3.jar')
    compile files('libs/jackson-core-asl-1.9.4.jar')
    compile files('libs/jsr305-1.3.9.jar')
    compile files('libs/maps.jar')
    compile 'com.google.guava:guava:11.0.1'
    compile 'com.google.protobuf:protobuf-java:2.2.0'
    compile 'com.google.android.gms:play-services:7.0.0'
    compile('com.google.android.gms:play-services-gcm:7.0.0') {
        exclude group: 'com.google.guava'
        exclude group: 'com.apache.http'
    }
    compile('com.google.android.gms:play-services-maps:7.0.0') {
        exclude group: 'com.google.guava'
        exclude group: 'com.apache.http'
    }
}

and my libs folder contains following jars:

enter image description here

proguard-project.txt

-keep class com.google.** {*;}
-keep interface com.google.** { *;}
-keep class com.slidingmenu.** {*;}
-keep class com.actionbarsherlock.** {*;}
-keep class com.ipaulpro.** {*;}
-keep class com.ianhanniballake.** {*;}

-dontwarn com.google.**
-dontwarn com.androidquery.**
-dontwarn org.apache.http.**
-dontwarn com.ianhanniballake.**
-dontwarn com.ipaulpro.**

-libraryjars /libs/google-api-client-1.10.3-beta.jar
-libraryjars /libs/google-api-client-android2-1.10.3-beta.jar
-libraryjars /libs/google-http-client-1.10.3-beta.jar
-libraryjars /libs/google-http-client-android2-1.10.3-beta.jar
-libraryjars /libs/google-oauth-client-1.10.1-beta.jar
-libraryjars /libs/jackson-core-asl-1.9.4.jar
-libraryjars /libs/guava-11.0.1.jar
-libraryjars /libs/jsr305-1.3.9.jar
-libraryjars /libs/protobuf-java-2.2.0.jar
-libraryjars /libs/maps.jar
-libraryjars /libs/httpclient-4.3.3.jar
-libraryjars /libs/httpcore-4.3.2.jar
-libraryjars /libs/httpmime-4.3.3.jar

All things are done finally and I can run my project also but when I try to Generate Sign Apk It gives me errors as:

Errors in Pastebin

I don't know why it happens as it is worked perfectly in Eclipse.

Any Help?

Community
  • 1
  • 1
Pratik Butani
  • 60,504
  • 58
  • 273
  • 437

2 Answers2

0

First of all, Android already comes with an implementation of Apache HTTPClient. Don't add a dependency on another one.

The bottom of your log file shows the message of the failure:

Can't read [/libs/google-api-client-1.10.3-beta.jar] (No such file or directory)

You can simply add all the jars in libs as a compile dependency with one line:

compile fileTree(dir: 'libs', include: ['*.jar'])

That should avoid having to call out each jar by name.

Lastly, I don't think you don't need any of the -libraryjars lines in your proguard config.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • Still getting `Warning:there were 1 unresolved references to classes or interfaces. You may need to add missing library jars or update their versions. If your code works fine without the missing classes, you can suppress the warnings with '-dontwarn' options.` – Pratik Butani Feb 11 '16 at 07:58
  • That's just a warning. Does it still work anyway? If not, can you tell what it's missing? – Doug Stevenson Feb 11 '16 at 08:07
0

Comment out the following line in your build.gradle :

compile files('libs/google-api-client-android2-1.10.3-beta-sources.jar')
BenJaminSila
  • 593
  • 5
  • 12