Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError with the aapt options --rename-manifest-package and --rename-instrumentation-target-package #385

Closed
franck-serot opened this issue Jun 3, 2014 · 3 comments

Comments

@franck-serot
Copy link

What steps will reproduce the problem?

  1. create an Android projet with the android-release archetype available on the link https://github.com/akquinet/android-archetypes

mvn archetype:generate -B -DarchetypeArtifactId=android-release -DarchetypeGroupId=de.akquinet.android.archetypes -DarchetypeVersion=1.0.11 -DgroupId=com.company.demo -DartifactId=demo -Dversion=1.0.0-SNAPSHOT -Dpackage=com.company.demo -Dandroid-plugin-version=3.8.2 -Demulator=default -Dplatform=16
cd demo
mvn clean install => all is ok

  1. In the projet Android, add configuration in the plugin android-maven-plugin :

< renameManifestPackage >${project.groupId}.foo.bar</ renameManifestPackage >

  1. In the projet Android-it, add configuration in the plugin android-maven-plugin :

< renameManifestPackage >${project.groupId}.foo.bar</ renameManifestPackage >
< renameInstrumentationTargetPackage >${project.groupId}.foo.bar</ renameInstrumentationTargetPackage >
< test >
< instrumentationPackage >${project.groupId}.foo.bar</ instrumentationPackage >
</ test >

What is the expected output?

mvn clean verify
...
[INFO] --- android-maven-plugin:3.8.2:internal-integration-test (default-internal-integration-test) @ android-demo-it ---
[INFO] Found 1 devices connected with the Android Debug Bridge
[INFO] android.device parameter not set, using all attached devices
[INFO] Device 4df19dd060da5f81_samsung_GT-I9300 found.
[INFO] 4df19dd060da5f81_samsung_GT-I9300 : Running tests for specified test package: com.company.demo.test
[INFO] 4df19dd060da5f81_samsung_GT-I9300 : Running instrumentation tests in com.company.demo.test
[INFO] 4df19dd060da5f81_samsung_GT-I9300 : Run started: com.company.demo.test, 1 tests:
[INFO] 4df19dd060da5f81_samsung_GT-I9300 : Start [1/1]: com.company.demo.test.HelloAndroidActivityTest#testActivity
[INFO] 4df19dd060da5f81_samsung_GT-I9300 : End [1/1]: com.company.demo.test.HelloAndroidActivityTest#testActivity
[INFO] 4df19dd060da5f81_samsung_GT-I9300 : Run ended: 632 ms
[INFO] Tests run: 1, Failures: 0, Errors: 0
[INFO] 4df19dd060da5f81_samsung_GT-I9300 : Report file written to D:\workshop\Perso\repo\git\perso\android-demo-parent\android-demo-it\target-dev\surefire-reports\TEST-4df19dd060da5f81_samsung_GT-I9300.xml
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] android-demo - Parent ............................. SUCCESS [0.163s]
[INFO] android-demo - Application ........................ SUCCESS [10.197s]
[INFO] android-demo-it - Integration tests ............... SUCCESS [29.012s]
[INFO] ------------------------------------------------------------------------

What do you see instead?

mvn clean verify
...
[INFO] --- android-maven-plugin:3.8.2:internal-integration-test (default-internal-integration-test) @ android-demo-it ---
[INFO] Found 1 devices connected with the Android Debug Bridge
[INFO] android.device parameter not set, using all attached devices
[INFO] Device 4df19dd060da5f81_samsung_GT-I9300 found.
[INFO] 4df19dd060da5f81_samsung_GT-I9300 : Running tests for specified test package: com.company.demo.test
[INFO] 4df19dd060da5f81_samsung_GT-I9300 : Running instrumentation tests in com.company.demo.dev
[INFO] 4df19dd060da5f81_samsung_GT-I9300 : Run started: com.company.demo.dev, 1 tests:
[INFO] 4df19dd060da5f81_samsung_GT-I9300 : Start [1/1]: android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests#testSuiteConstructionFailed
[INFO] 4df19dd060da5f81_samsung_GT-I9300 : ERROR:android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests#testSuiteConstructionFailed
[INFO] 4df19dd060da5f81_samsung_GT-I9300 : java.lang.RuntimeException: Exception during suite construction
at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests.testSuiteConstructionFailed(TestSuiteBuilder.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1738)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.test.suitebuilder.TestMethod.instantiateTest(TestMethod.java:87)
at android.test.suitebuilder.TestMethod.createTest(TestMethod.java:73)
at android.test.suitebuilder.TestSuiteBuilder.addTest(TestSuiteBuilder.java:262)
at android.test.suitebuilder.TestSuiteBuilder.build(TestSuiteBuilder.java:184)
at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:379)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4675)
at android.app.ActivityThread.access$1400(ActivityThread.java:159)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5419)
at java.lang.reflect.Method.invokeNative(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1046)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:862)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: com.company.demo.HelloAndroidActivity
at com.company.demo.test.HelloAndroidActivityTest.(HelloAndroidActivityTest.java:9)
... 18 more

[INFO] 4df19dd060da5f81_samsung_GT-I9300 : End [1/1]: android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests#testSuiteConstructionFailed
[INFO] 4df19dd060da5f81_samsung_GT-I9300 : Run ended: 24 ms
[ERROR] 4df19dd060da5f81_samsung_GT-I9300 : FAILURES!!!
[INFO] Tests run: 1, Failures: 0, Errors: 1
[INFO] 4df19dd060da5f81_samsung_GT-I9300 : Report file written to D:\workshop\Perso\repo\git\perso\android-demo-parent\android-demo-it\target-dev\surefire-reports\TEST-4df19dd060
da5f81_samsung_GT-I9300.xml
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] android-demo - Parent ............................. SUCCESS [0.112s]
[INFO] android-demo - Application ........................ SUCCESS [11.781s]
[INFO] android-demo-it - Integration tests ............... FAILURE [2:26.717s]
[INFO] ------------------------------------------------------------------------

Error :
Caused by: java.lang.NoClassDefFoundError: com.company.demo.HelloAndroidActivity
at com.company.demo.test.HelloAndroidActivityTest.(HelloAndroidActivityTest.java:9)

Except I'm mistaken, the class HelloAndroidActivity should be always found in the package com.company.demo even thouth the manifest package is renamed.

--rename-manifest-package
Rewrite the manifest so that its package name is the package name
given here. Relative class names (for example .Foo) will be
changed to absolute names with the old package so that the code
does not need to change.
--rename-instrumentation-target-package
Rewrite the manifest so that all of its instrumentation
components target the given package. Useful when used in
conjunction with --rename-manifest-package to fix tests against
a package that has been renamed.

What version of maven-android-plugin are you using?

android-maven-plugin:3.8.2

What are the complete output lines of "mvn -version" on your machine?

$ mvn --version
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 17:22:22+0200)
Maven home: d:\bin\apache-maven-3.1.1
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: c:\Program Files (x86)\Java\jdk1.7.0_45\jre
Default locale: fr_FR, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

Please provide any additional information below.

@franck-serot
Copy link
Author

I post a link to project that fails.
https://github.com/franck-serot/demo
I don't think the problem is the android-release archetype (https://github.com/akquinet/android-archetypes) but I think either I don't use correctly the plugin android-maven-plugin or there is a bug.
Thank you in advance for your help.
Franck

@william-ferguson-au
Copy link
Contributor

It works right up until you configure

<test>
    <instrumentationPackage>${project.groupId}.foo.bar</instrumentationPackage>
</test>

on the POM in the it module.

The IT mechanisms aren't my strong suite. Anyone else want to chip in?

@mosabua
Copy link
Member

mosabua commented May 3, 2019

Closing old issue as cleanup

@mosabua mosabua closed this as completed May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants