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

Error in Build with 2.59.0 SNAPSHOT: netscape\javascript\package-info;' cannot be represented in dex format #2

Closed
sengsational opened this issue Mar 7, 2022 · 13 comments

Comments

@sengsational
Copy link

sengsational commented Mar 7, 2022

build.grade:

    dependencies {
        implementation 'net.sourceforge.htmlunit:htmlunit-android:2.59.0-SNAPSHOT'
        ...
    }

Error found under jetified-htmlunit-android-2.59.0-SNAPSHOT.jar:

    com.android.tools.r8.internal.r8: Class descriptor 'Lnetscape\javascript\package-info;' cannot be represented in dex format.

Running gradlew -q app:dependencies --configuration releaseRuntimeClasspath:

+--- net.sourceforge.htmlunit:htmlunit-android:2.59.0-SNAPSHOT
|    +--- xalan:xalan:2.7.2
|    |    \--- xalan:serializer:2.7.2
|    +--- org.apache.commons:commons-lang3:3.12.0
|    +--- org.apache.commons:commons-text:1.9
|    +--- commons-io:commons-io:2.10.0
|    +--- commons-logging:commons-logging:1.2
|    +--- commons-net:commons-net:3.8.0
|    +--- commons-codec:commons-codec:1.15
|    +--- org.brotli:dec:0.1.2
|    +--- com.shapesecurity:salvation2:3.0.0
|    \--- org.eclipse.jetty.websocket:websocket-client:9.4.45.v20220203
|         +--- org.eclipse.jetty:jetty-client:9.4.45.v20220203
|         |    +--- org.eclipse.jetty:jetty-http:9.4.45.v20220203
|         |    |    +--- org.eclipse.jetty:jetty-util:9.4.45.v20220203
|         |    |    \--- org.eclipse.jetty:jetty-io:9.4.45.v20220203
|         |    |         \--- org.eclipse.jetty:jetty-util:9.4.45.v20220203
|         |    \--- org.eclipse.jetty:jetty-io:9.4.45.v20220203 (*)
|         +--- org.eclipse.jetty:jetty-util:9.4.45.v20220203
|         +--- org.eclipse.jetty:jetty-io:9.4.45.v20220203 (*)
|         \--- org.eclipse.jetty.websocket:websocket-common:9.4.45.v20220203
|              +--- org.eclipse.jetty.websocket:websocket-api:9.4.45.v20220203
|              +--- org.eclipse.jetty:jetty-util:9.4.45.v20220203
|              \--- org.eclipse.jetty:jetty-io:9.4.45.v20220203 (*)

Earlier package-info issue: HtmlUnit/htmlunit#133 (comment)

@lqh995204185
Copy link

@sengsational
I directly download the jar package and import it

implementation files('libs/htmlunit-android-2.59.0.jar')

I also encountered this problem. How can I solve it

@lqh995204185
Copy link

@sengsational
delete:
/javascript/package-info
/netscape/javascript/package-info

Now it has worked for me in Android studio
But I'm not sure if it works in practice

@zerorooot
Copy link

zerorooot commented Mar 11, 2022

I try to add some content to filter in pom.xml file

<exclude>netscape/package-info.class</exclude>
<exclude>netscape/javascript/package-info.class</exclude>

and delete lines 61~63

<exclude>commons-codec:commons-codec</exclude>
<exclude>commons-io:*</exclude>
<exclude>commons-logging:*</exclude>

Finally, add in Android studio

implementation files('libs/htmlunit-android-2.59.0.jar')
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'

Now it has worked for me in Android studio

@sengsational
Copy link
Author

@zerorooot @lqh995204185 Thank you for the suggestions. I am unable to make progress. I am afraid that because I do not have proper context to know where and how to make the suggested changes, I am getting a Transform's input file does not exist error. Please advise me what I'm doing wrong and more detailed steps for me to make these changes.

Here are the steps I executed:

  1. Locate htmlunit-android-2.59.0.jar (found in C:\Users\Owner\.gradle\caches\modules-2\files-2.1\net.sourceforge.htmlunit\htmlunit-android\2.59.0-SNAPSHOT\ed7b1a0371f6a0184a2cc63552086f0245295531\htmlunit-android-2.59.0.jar)

  2. Rename htmlunit-android-2.59.0.jar to htmlunit-android-2.59.0.zip

  3. Extract htmlunit-android-2.59.0.zip to tmp

  4. Edit 'tmp\htmlunit-android-2.59.0-SNAPSHOT\META-INF\maven\net.sourceforge.htmlunit\htmlunit-android\pom.xml'

Resulting in:

<build>
<plugins>
....
  <plugin>
    <artifactId>maven-shade-plugin</artifactId>
    <executions>
      <execution>
....
        </goals>
        <configuration>
          <artifactSet>
            <excludes>
              <exclude>org.apache.commons:*</exclude>
              <exclude>commons-net:*</exclude>
              <exclude>org.brotli:*</exclude>
              <exclude>com.shapesecurity:*</exclude>
              <exclude>xalan:*</exclude>
              <exclude>org.eclipse.jetty.websocket:*</exclude>
              <exclude>org.eclipse.jetty:*</exclude>
              <exclude>netscape/package-info.class</exclude>
              <exclude>netscape/javascript/package-info.class</exclude>
            </excludes>
  1. Zip htmlunit-android-2.59.0.zip and rename to htmlunit-android-2.59.0.jar

  2. Place the htmlunit-android-2.59.0.jar file in C:\Users\Owner\AndroidStudioProjects\MyApplication2\app\libs\ folder.

  3. Edit build.gradle:

 dependencies {

    //implementation 'net.sourceforge.htmlunit:htmlunit-android:2.59.0-SNAPSHOT' (removed)  
    implementation files('libs/htmlunit-android-2.59.0.jar')
    implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'

RESULTING ERROR:

Transform's input file does not exist: C:\Users\Owner\AndroidStudioProjects\MyApplication2\app\libs\htmlunit-android-2.59.0.jar. (See https://issuetracker.google.com/issues/158753935)

@zerorooot
Copy link

zerorooot commented Mar 14, 2022

@zerorooot @lqh995204185 Thank you for the suggestions. I am unable to make progress. I am afraid that because I do not have proper context to know where and how to make the suggested changes, I am getting a Transform's input file does not exist error. Please advise me what I'm doing wrong and more detailed steps for me to make these changes.

Here are the steps I executed:

  1. Locate htmlunit-android-2.59.0.jar (found in C:\Users\Owner\.gradle\caches\modules-2\files-2.1\net.sourceforge.htmlunit\htmlunit-android\2.59.0-SNAPSHOT\ed7b1a0371f6a0184a2cc63552086f0245295531\htmlunit-android-2.59.0.jar)
  2. Rename htmlunit-android-2.59.0.jar to htmlunit-android-2.59.0.zip
  3. Extract htmlunit-android-2.59.0.zip to tmp
  4. Edit 'tmp\htmlunit-android-2.59.0-SNAPSHOT\META-INF\maven\net.sourceforge.htmlunit\htmlunit-android\pom.xml'

Resulting in:

<build>
<plugins>
....
  <plugin>
    <artifactId>maven-shade-plugin</artifactId>
    <executions>
      <execution>
....
        </goals>
        <configuration>
          <artifactSet>
            <excludes>
              <exclude>org.apache.commons:*</exclude>
              <exclude>commons-net:*</exclude>
              <exclude>org.brotli:*</exclude>
              <exclude>com.shapesecurity:*</exclude>
              <exclude>xalan:*</exclude>
              <exclude>org.eclipse.jetty.websocket:*</exclude>
              <exclude>org.eclipse.jetty:*</exclude>
              <exclude>netscape/package-info.class</exclude>
              <exclude>netscape/javascript/package-info.class</exclude>
            </excludes>
  1. Zip htmlunit-android-2.59.0.zip and rename to htmlunit-android-2.59.0.jar
  2. Place the htmlunit-android-2.59.0.jar file in C:\Users\Owner\AndroidStudioProjects\MyApplication2\app\libs\ folder.
  3. Edit build.gradle:
 dependencies {

    //implementation 'net.sourceforge.htmlunit:htmlunit-android:2.59.0-SNAPSHOT' (removed)  
    implementation files('libs/htmlunit-android-2.59.0.jar')
    implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'

RESULTING ERROR:

Transform's input file does not exist: C:\Users\Owner\AndroidStudioProjects\MyApplication2\app\libs\htmlunit-android-2.59.0.jar. (See https://issuetracker.google.com/issues/158753935)

You need to recompile a copy based on the source code, instead of directly changing the htmlunit-android-2.59.0.jar file

sengsational added a commit to sengsational/htmlunit-android that referenced this issue Mar 14, 2022
Fix problem when compiling in Android HtmlUnit#2
@sengsational
Copy link
Author

You need to recompile a copy based on the source code, instead of directly changing the htmlunit-android-2.59.0.jar file

I have not found instructions for building the htmlunit-android project in Android studio.

My first attempts at building the htmlunit-android project in Android studio have not succeeded.

I have started adding instructions, but do not know the appropriate steps to complete the build. Please make a pull request for https://github.com/sengsational/htmlunit-android/edit/main/README.md . I will work through the steps that you provide and add detail, if needed.

Building Project Source

To build this project in Android Studio:

  • Fork the project to your own repository using the fork button here: https://github.com/HtmlUnit/htmlunit-android.
  • In Android Studio, select VCS > Get from Version Control... > https://github.com/(yourGitHubId)/htmlunit-android > Clone button > New Window
  • // TODO: PLEASE UPDATE THIS OF STEPS SO THAT THE RESULT SPECIFIES HOW TO BUILD THE PROJECT IN ANDROID STUDIO

@rbri
Copy link
Member

rbri commented Mar 14, 2022

To try to make it a bit more clear:

@rbri
Copy link
Member

rbri commented Mar 14, 2022

@zerorooot

commons-codec:commons-codec
commons-io:
commons-logging:

Why you think we have to shade this jars - is there some conflict with the android sdk classes or is this something special for your project?

@sengsational
Copy link
Author

there is an updated version of the compiler plugin, the latest snapshot (2.60.0-SNAPSHOT) is build using the fixed version. Please try and check if the problem is gone.

This version has resolved my problem.

Specifically, to build.gradle (:app), I simply added:

dependencies {
    implementation 'net.sourceforge.htmlunit:htmlunit-android:2.60.0-SNAPSHOT'
    ....

The above requires that settings.gradle (applicationName) include:

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
    repositories {
        ....
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots'}
        ....

@zerorooot
Copy link

@rbri
When I exclude the package-info.class file, after importing and compiling, report errors

java.lang.NoClassDefFoundError

So i removed it.

@rbri
Copy link
Member

rbri commented Mar 15, 2022

@zerorooot can you please check with the latest snapshot build
And if you still het this classnotfound exception please include the name of the class from the exception

@zerorooot
Copy link

@rbri
Everything works fine with the latest snapshot build, thank you very much

@rbri
Copy link
Member

rbri commented Mar 16, 2022

@zerorooot a release is planned for this weekend.
Thanks for the feedback.

@rbri rbri closed this as completed Dec 9, 2022
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

4 participants