voc icon indicating copy to clipboard operation
voc copied to clipboard

Android build fails (bad descriptor: Lpython/__phello__.foo)

Open MatBonv opened this issue 5 years ago • 6 comments

When I try to build the android app of hello world, this error occures:

Writing build/intermediates/classes/debug\python\travertino/__init__.class ...
:mergeDebugShaders UP-TO-DATE
:compileDebugShaders UP-TO-DATE
:generateDebugAssets UP-TO-DATE
:mergeDebugAssets UP-TO-DATE
:transformClassesWithDexForDebug
Dex: Error converting bytecode to dex:
Cause: java.lang.RuntimeException: Exception parsing classes
    UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Exception parsing classes
  at com.android.dx.command.dexer.Main.processClass(Main.java:775)
       at com.android.dx.command.dexer.Main.processFileBytes(Main.java:741)
   at com.android.dx.command.dexer.Main.access$1200(Main.java:88)
 at com.android.dx.command.dexer.Main$FileBytesConsumer.processFileBytes(Main.java:1683)
        at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
       at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
  at com.android.dx.command.dexer.Main.processOne(Main.java:695)
 at com.android.dx.command.dexer.Main.processAllFiles(Main.java:592)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:321)
 at com.android.dx.command.dexer.Main.run(Main.java:292)
        at com.android.builder.internal.compiler.DexWrapper.run(DexWrapper.java:54)
    at com.android.builder.core.DexByteCodeConverter.lambda$dexInProcess$0(DexByteCodeConverter.java:173)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
     at java.lang.Thread.run(Thread.java:748)
Caused by: com.android.dx.cf.iface.ParseException: bad descriptor: Lpython/__phello__.foo;
    at com.android.dx.cf.cst.ConstantPoolParser.parse0(ConstantPoolParser.java:347)
        at com.android.dx.cf.cst.ConstantPoolParser.parse(ConstantPoolParser.java:150)
 at com.android.dx.cf.cst.ConstantPoolParser.parseIfNecessary(ConstantPoolParser.java:124)
      at com.android.dx.cf.cst.ConstantPoolParser.getPool(ConstantPoolParser.java:115)
       at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:482)
   at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
    at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
     at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
 at com.android.dx.command.dexer.Main.parseClass(Main.java:787)
 at com.android.dx.command.dexer.Main.access$1600(Main.java:88)
 at com.android.dx.command.dexer.Main$ClassParserTask.call(Main.java:1722)
      at com.android.dx.command.dexer.Main.processClass(Main.java:773)
       ... 16 more
Caused by: java.lang.IllegalArgumentException: bad descriptor: Lpython/__phello__.foo;
     at com.android.dx.rop.type.Type.intern(Type.java:356)
  at com.android.dx.rop.type.Type.internClassName(Type.java:420)
 at com.android.dx.cf.cst.ConstantPoolParser.parse0(ConstantPoolParser.java:289)
        ... 27 more

1 error; aborting
:transformClassesWithDexForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

I tried to use python setup.py android --support-pkg https://pybee-briefcase-support.s3-us-west-2.amazonaws.com/Python-Android-support/3.5/Android/Python-3.5-Android-support.b5.tar.gz --build --start as a workaround (mentioned in #708) but it gives the same error. Any help is welcome.

MatBonv avatar Apr 08 '19 18:04 MatBonv

The underlying problem is that VOC is currently generating invalid bytecode for one of the data structures contained in travertino.

If you use a stable version of Toga (i.e., 0.2.15) and the old build of Android-support, you should have more luck; but the development branch of Toga isn't compatible with VOC at this time.

freakboy3742 avatar Apr 09 '19 05:04 freakboy3742

Alright, thanks for answering. But how do I use an other version of Toga? It will automatically collect the latest version.

MatBonv avatar Apr 09 '19 11:04 MatBonv

If you look at the setup.py file for your project (the one generated by build new), it will list toga as a dependency, specifying a version of "==0.3.0.dev11" in a couple of places (one for the core, and for each platform, too). If you change that to "==0.2.15", you'll get a different version.

freakboy3742 avatar Apr 10 '19 07:04 freakboy3742

Ok thanks, so I changed the version to 0.2.15 and ran python setup.py android --support-pkg https://pybee-briefcase-support.s3-us-west-2.amazonaws.com/Python-Android-support/3.5/Android/Python-3.5-Android-support.b5.tar.gz --build --start (also tried b3, b4 and b6), but the same error occures...

MatBonv avatar Apr 10 '19 09:04 MatBonv

The __phello__.foo module also needs to be excluded from the Ouroboros build - see #956.

dboddie avatar Jun 30 '19 17:06 dboddie

Jeff Smith @whydoubt points out in this message, the period in __phello__.foo makes it an invalid class name.

dboddie avatar Jul 16 '19 22:07 dboddie