Build error when including com.squareup.okio JAR


(Matt Robertson) #1

When I include the com.squareup.okio JAR in my project, the elements compiler fails to build with error AP1: Error while running Android tool: dx.bat.

The jar I’m referring to is located here https://repo1.maven.org/maven2/com/squareup/okio/okio/2.1.0/

I downloaded the jar and am referencing it as a Direct Reference in my project:

<Reference Include="okio-2.1.0.jar">
  <HintPath>C:\Android\okio-2.1.0.jar</HintPath>
  <Private>True</Private>
</Reference>

Here is the ebuild --debug output.
eout.txt (6.1 MB)


(Matt Robertson) #2

When I set the private attribute to False, the project builds, but then crashes at Runtime with java.lang.ClassNotFoundException: Didn't find class "okio.Buffer". The okio jar is referenced by another jar I’m including (Squareup’s okhttp3). What exactly does the private tag do?


(marc hoffman) #3

Private is the internal name (MSBuild legacy) for Copy Local. For Android, it means that the .jar file will be included in the DEXed binary (opposed to being available somewhere else externally, at runtime). For Android, really all .jars except the main android.jar must be embedded.

IOW, it’s perfectly expected that if you don’t Copy Local the reference, that the class will be missing at runtime.

As for why it fails to DEX with the reference, I’ll ned to investigate. But your build log does not include the actual DEX error — in your log, the build failed omg the compile phase, with errors such as

E: Globals are disabled in the project settings [C:\Users\mattr\Code\Accordance\android\AccordanceAndroid\com.accordancebible.Accordance\TheCommonCode\p105SingleVerse.pas (4911)]
E: Modifier mismatch for parameter 2, expected "var" but found "in" [C:\Users\mattr\Code\Accordance\android\AccordanceAndroid\com.accordancebible.Accordance\UX\AdvancedSearchDialogFragment.pas (96)]

it seems that you will want to review your project options to make sure AllowGlobals is not set to false (it default to true now, so my guess is that your project has it explicitly set to false), and to explicitly set AllowLegacyOutParameters to true (it defaults to false).

I’ll download the .jar now and will see if I can repro the DEX error on my end, in a plain project…


(marc hoffman) #5

I’m afraid I cannot reproduce this. created a new Android project form, template, added the downloaded .jar as reference, and ir builds and DEXes fine:

                     dex> processing com/remobjects/elements/system/__Global.class...
                     dex> processing archive /Users/mh/Downloads/okio-2.1.0.jar...
                     dex> ignored resource META-INF/
                     dex> ignored resource META-INF/MANIFEST.MF
                     dex> ignored resource META-INF/jvm.kotlin_module
                     dex> ignored resource META-INF/proguard/
                     dex> ignored resource META-INF/proguard/okio.pro
                     dex> ignored resource okio/
                     dex> processing okio/-Base64.class...
                     dex> processing okio/-DeflaterSinkExtensions.class...
                     dex> processing okio/-DeprecatedOkio.class...
                     dex> processing okio/-DeprecatedUpgrade.class...
                     dex> processing okio/-DeprecatedUtf8.class...
                     dex> processing okio/-GzipSinkExtensions.class...
                     dex> processing okio/-GzipSourceExtensions.class...
                     dex> processing okio/-InflaterSourceExtensions.class...
                     dex> processing okio/-Platform.class...
                     dex> processing okio/-Util.class...
                     dex> processing okio/AsyncTimeout.class...
                     dex> processing okio/AsyncTimeout$Companion.class...
                     dex> processing okio/AsyncTimeout$Watchdog.class...
                     dex> processing okio/AsyncTimeout$sink$1.class...
                     dex> processing okio/AsyncTimeout$source$1.class...
                     dex> processing okio/BlackholeSink.class...
                     dex> processing okio/Buffer.class...
                     dex> processing okio/Buffer$Companion.class...
                     dex> processing okio/Buffer$UnsafeCursor.class...
                     dex> processing okio/Buffer$inputStream$1.class...
                     dex> processing okio/Buffer$outputStream$1.class...
                     dex> processing okio/BufferedSink.class...
                     dex> processing okio/BufferedSource.class...
                     dex> processing okio/ByteString.class...
                     dex> processing okio/ByteString$Companion.class...
                     dex> processing okio/DeflaterSink.class...
                     dex> processing okio/ForwardingSink.class...
                     dex> processing okio/ForwardingSource.class...
                     dex> processing okio/ForwardingTimeout.class...
                     dex> processing okio/GzipSink.class...
                     dex> processing okio/GzipSource.class...
                     dex> processing okio/HashingSink.class...
                     dex> processing okio/HashingSink$Companion.class...
                     dex> processing okio/HashingSource.class...
                     dex> processing okio/HashingSource$Companion.class...
                     dex> processing okio/InflaterSource.class...
                     dex> processing okio/InputStreamSource.class...
                     dex> processing okio/Okio.class...
                     dex> processing okio/Options.class...
                     dex> processing okio/Options$Companion.class...
                     dex> processing okio/OutputStreamSink.class...
                     dex> processing okio/PeekSource.class...
                     dex> processing okio/Pipe.class...
                     dex> processing okio/Pipe$sink$1.class...
                     dex> processing okio/Pipe$source$1.class...
                     dex> processing okio/RealBufferedSink.class...
                     dex> processing okio/RealBufferedSink$outputStream$1.class...
                     dex> processing okio/RealBufferedSource.class...
                     dex> processing okio/RealBufferedSource$inputStream$1.class...
                     dex> processing okio/Segment.class...
                     dex> processing okio/Segment$Companion.class...
                     dex> processing okio/SegmentPool.class...
                     dex> processing okio/SegmentedByteString.class...
                     dex> processing okio/Sink.class...
                     dex> processing okio/SocketAsyncTimeout.class...
                     dex> processing okio/Source.class...
                     dex> processing okio/Timeout.class...
                     dex> processing okio/Timeout$Companion.class...
                     dex> processing okio/Timeout$Companion$NONE$1.class...
                     dex> processing okio/Utf8.class...
                     dex> ignored resource okio/internal/
                     dex> processing okio/internal/ByteStringKt.class...
                     dex> processing okio/internal/_Utf8Kt.class...
                     dex> processing archive /Users/mh/Library/Application Support/RemObjects Software/EBuild/Obj/com.remobjects.androidapplication43-8E6B4405332794035A57F0D018D9BE01952DEAE7/Debug/Cooper-Android/com.remobjects.androidapplication43.jar...
                     dex> ignored resource DEBUG_INFO/

I’ll need to see your error messages or your project to comment further…


(marc hoffman) #6

Oh wait, and I also see you’re using Version 9.3.103.2211. All bets are off with that, then, may well be a bug we fixed in the 14 months since that shipped :wink:


(Matt Robertson) #7

I should have mentioned that :slight_smile: good to know it’s compiling on the latest release. Now I just need to get my code compiling on the latest release :slight_smile:


(marc hoffman) #8

Note that I can’t be sure that that’s the difference, since husky its not the compile itself that fails, but DEX (which isn’t ours, its a tool from the Android tool chain). I suggets you try updating top the latest Android tools, if you haven’t yet. the version of DEX I used is sdk/build-tools/28.0.0-rc1/lib/dx.jar.

In essence, I can see three potential scenarios here:

  • it’s a bug in DEX that got fixed. If that’s the case, updating the Android tools may help
  • it’s a bug/difference in there compiler that we fixed (indirectly) between 9.3 and latest
  • it’s something more complex in the interaction between that jar and your code that makes DEX fail (in this case, it might still fail for you, even in v10, and we’d need to investigate further.

I suggest

  1. updates the tools
  2. try creating a new Apple add the jar, build. does that work, or does it fail too?
  3. send me the DEX output from the failed build (be it the new app, or your actual project).

(Matt Robertson) #9

Thanks Marc I’ll take a look at that.