androidannotations / androidannotations

Fast Android Development. Easy maintainance.
Other
11.06k stars 2.35k forks source link

java.lang.NoClassDefFoundError: org.springframework.web.util.UriTemplate #1670

Closed han361769045 closed 8 years ago

han361769045 commented 8 years ago

12-28 21:40:28.755 28469-28469/com.zczczy.leo.fuwuwangapp E/dalvikvm: Could not find class 'org.springframework.web.util.UriTemplate', referenced from method org.springframework.web.client.RestTemplate.execute

12-28 21:40:29.045 28469-28504/com.zczczy.leo.fuwuwangapp E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-2 Process: com.zczczy.leo.fuwuwangapp, PID: 28469 java.lang.NoClassDefFoundError: org.springframework.web.util.UriTemplate at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:498) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:447) at com.zczczy.leo.fuwuwangapp.rest.NewMyRestClient.getFirstClass(NewMyRestClient.java:432) at com.zczczy.leo.fuwuwangapp.activities.IndexActivity.getCategory(IndexActivity.java:71) at com.zczczy.leo.fuwuwangapp.activities.IndexActivity.access$401(IndexActivity.java:35) at com.zczczy.leo.fuwuwangapp.activities.IndexActivity$5.execute(IndexActivity.java:169) at org.androidannotations.api.BackgroundExecutor$Task.run(BackgroundExecutor.java:401) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:152) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:265) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841)

dodgex commented 8 years ago

not sure if this is an AA issue. looks more like a issue in your dependencies configuration.

han361769045 commented 8 years ago

it works before,but just now it broke, and then it works again

dodgex commented 8 years ago

what? i do not understand what you mean.

han361769045 commented 8 years ago

this project works OK, but just now I tested it on the phone , it told me that

WonderCsabo commented 8 years ago

@dodgex is right, you have wrong dependency configuration. Please post the relevant part of your build script.

han361769045 commented 8 years ago

thanks for your answer I 'll check it again.

han361769045 commented 8 years ago
apply plugin: 'com.android.application'
apply plugin: 'android-apt'

def AAVersion = '3.3.2'

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

apt {
    arguments {
        androidManifestFile variant.outputs[0]?.processResources?.manifestFile
        resourcePackageName 'com.zczczy.leo.fuwuwangapp'
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.zczczy.leo.fuwuwangapp"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 9
        versionName "1.1"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }

}

dependencies {
    apt "org.androidannotations:androidannotations:$AAVersion"
    compile "org.androidannotations:androidannotations-api:$AAVersion"
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.squareup.okhttp:okhttp:2.6.0'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.code.gson:gson:2.5'
    compile 'com.squareup:otto:1.3.8'
    compile 'me.himanshusoni.quantityview:quantity-view:1.1.1'
    compile 'com.daimajia.slider:library:1.1.5@aar'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.6.3'
    compile 'com.flyco.dialog:FlycoDialog_Lib:1.2.2@aar'
    compile 'com.flyco.animation:FlycoAnimation_Lib:1.0.0@aar'
    compile 'com.marshalchen.ultimaterecyclerview:library:0.3.18'
    compile 'com.j256.ormlite:ormlite-android:4.48'
    compile 'com.j256.ormlite:ormlite-core:4.48'
    compile project(':infiniteautoscroolviewlibrary')
    compile project(':zxingcapturelibrary')

}
WonderCsabo commented 8 years ago

This seems to be okay. Make sure you do not have other jars in your libs folder. Also can you post the result of ./gradlew :app:dependencies?

han361769045 commented 8 years ago

@SharedPref(value = SharedPref.Scope.UNIQUE) public interface MyPrefs { @DefaultString("") String picture(); }

Thank U! I've found the mistake, if the method is "picture" in MyPrefs ,the problem will appear

han361769045 commented 8 years ago

I close this issue Thanks.

kot331107 commented 7 years ago

Sorry guys, but I've a bit stucked with the same issue in a start of developing my app... :( It appears after I've added a "picasso" dependency to my build.gradle, likewise topicstarter. Oh, and BTW thanks a lot for an amazing lib!

Console log:

E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1 java.lang.NoClassDefFoundError: org.springframework.web.util.UriTemplate at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:498) at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:472) at com.clockbyte.woodpecker.web.RestClient.getFeed(RestClient.java:48) at com.clockbyte.woodpecker.activities.MainActivity.fetchFeed(MainActivity.java:208) at com.clockbyte.woodpecker.activities.MainActivity.access$601(MainActivity.java:41) at com.clockbyte.woodpecker.activities.MainActivity$8.execute(MainActivity.java:204) at org.androidannotations.api.BackgroundExecutor$Task.run(BackgroundExecutor.java:403) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) at java.util.concurrent.FutureTask.run(FutureTask.java:137) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:150) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:264) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) at java.lang.Thread.run(Thread.java:864)

Code which throws an exception (in MainActivity):

    @Background
    void fetchFeed(){
        showIndicator(true);
        List<FeedItem> feedItems =  restClient.getFeed(); // here I got the exception
        fetchFeedUI(feedItems);
    }

REST client code

@Rest(rootUrl = DomainUrl + PostUrl, converters = { MappingJackson2HttpMessageConverterEx.class })
public interface RestClient extends RestClientErrorHandling {
    @Get(GetFeedUrl)
    List<FeedItem> getFeed();

    @Get(GetFeedUrl + PageParamUrl)
    List<FeedItem> getFeedByPage(@Path int page);

    @Post(NewUrl)
    @Accept(MediaType.APPLICATION_JSON)
    void sendNewPost(@Body PostItem postItem);
}

My build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
def AAVersion = '4.1.0'
def ParcelerVersion = '1.1.5'

apt {
    arguments {
        resourcePackageName android.defaultConfig.applicationId
        androidManifestFile variant.outputs[0]?.processResources?.manifestFile
    }
}

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        applicationId "com.clockbyte.woodpecker"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        multiDexEnabled = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions{
        pickFirst 'META-INF/LICENSE'
    }

    dexOptions {
        preDexLibraries = false
    }

    afterEvaluate {
        tasks.matching {
            it.name.startsWith('dex')
        }.each { dx ->
            if (dx.additionalParameters == null) {
                dx.additionalParameters = ['--multi-dex']
            } else {
                dx.additionalParameters += '--multi-dex'
            }
        }
    }
}

configurations.all {
    resolutionStrategy.force 'com.google.android.gms:play-services-ads:9.6.1'
}

dependencies {
    apt "org.androidannotations:androidannotations:$AAVersion"
    compile "org.androidannotations:androidannotations-api:$AAVersion"
    apt "org.androidannotations:rest-spring:$AAVersion"
    compile "org.androidannotations:rest-spring-api:$AAVersion"

    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'org.apache.commons:commons-io:1.3.2'

    compile 'com.android.support:support-v4:25.0.1'
    compile 'com.android.support:recyclerview-v7:25.0.1'
    compile 'com.android.support:appcompat-v7:25.0.1'
    compile 'com.android.support:design:25.0.1'
    compile 'com.google.firebase:firebase-core:9.6.1'
    compile 'com.google.firebase:firebase-analytics:9.6.1'
    compile 'joda-time:joda-time:2.9.3'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.8.4'
    compile 'com.fasterxml.jackson.core:jackson-core:2.8.4'
    compile 'com.fasterxml.jackson.core:jackson-annotations:2.8.4'
    compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.8.4'
    compile 'org.ocpsoft.prettytime:prettytime:4.0.1.Final'
    compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
    compile 'com.github.clockbyte:admobadapter:1.3.0'
    compile 'pub.devrel:easypermissions:0.2.0'
    compile 'com.squareup.picasso:picasso:2.5.2'

    compile 'com.android.support:multidex:1.0.1'

    apt "org.parceler:parceler:$ParcelerVersion"
    compile "org.parceler:parceler-api:$ParcelerVersion"

    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
WonderCsabo commented 7 years ago

Sorry, but this is not an AA issue. Please consult the Spring or Picasso libraries for conflicting dependencies.

kot331107 commented 7 years ago

@WonderCsabo Sure, it was written just for your info and your knowledgebase. I'm trying to get with it right now.