I have a .aar file that contains a SDK, it needs the gson library to work, so i added the gson.jar file into the project as a ReferenceJar, but it cannot find the reference.
I've already tried to extract the jar from the aar, and use one as InputJar and the gson jar as ReferenceJar, it did not work.
In this case the java code spits this error:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/gson/Gson;
I've tried to create a separate project that contains only the gson file as a InputJar and use it as a dependency on the other project.
In this case the gson project does not compile, VS spits errors like
CS0534 "CollectionTypeAdapterFactory.Adapter" does not implement inherited abstract member "TypeAdapter.Read(JsonReader)"
I've also tried to add the gson.jar file into the libs folder inside the .aar file, but gave me the same compiling errors as described above
So, what should I do next?
I figured out.
I had to extract the jar from the .aar and set it as an EmbeddedJar and the gson library as EmbeddedReferenceJar. Somehow it worked. If someone could explain me why, it would be nice.
Related
I'm trying to generate a jar file of my kotlin project.
I read Maven Kotlin and copied the code into my pom.xml but I don't understand what I'm supposed to insert at ${main.class}.
Here is my code architecture with MorisKt.java as my main class.
I tried MorisKt.class, /MorisKt.class, target/Moris.class(container folder of my compiled code)
And nothing worked. The jar is generated but I have Could not find or load main class when I try to run it.
If you can explain me where I'm doing it wrong
You need to put your main class file in a package and then reference it with the fully qualified name.
For instance if you put your Moris.kt in a package named app it would be :
<mainClass>app.MorisKt</mainClass>
I was trying to run the sample code from the sdk but I got the java.lang.NoClassDefFoundError, at the line:
sinchClient = Sinch.getSinchClientBuilder()
.context(this)
.userId("a")
.applicationKey("key")
.applicationSecret("secret")
.environmentHost("sandbox.sinch.com")
.build();
NoClassDefFoundError means it can't find the class. This is most likely because the Sinch RTC SDK is not properly included in your APK. Make sure that the .jar file is under your libs/ folder (or, if you are using a custom setup, make sure it's being compiled in to the final package).
I'm trying to add ActionbarSherlock as dependency using line I got from gradleplease
(Instead of these methods. At least according to this link:
"In Gradle you no longer need to add in these libraries as source code projects; you can simply refer to them as dependencies, and the build system will handle the rest; downloading, merging in resources and manifest entries, etc. For each library, look up the corresponding AAR library dependency name (provided the library in question has been updated as a android library artifact), and add these to the dependency section."
this setup should not be necessary anymore)
But it doesn't work and module settings in Android studio shows error: "Library 'ComActionbarsherlockComActionbarsherlock440.aar': Invalid classes root"
Any idea?
Add these line in your module build.gradle
dependencies {
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
}
I'm trying all I can to add an external JAR file to my project but I just can't do it. Here's what I'm doing atm:
Copying JAR to libs folder
Hitting "Add as library" and selecting jar package option
Modifying build.gradle to include the new jar, I'm doing it simply like this:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
Yet I'm still getting some weird error on Pre Dex phase:
Android Pre Dex: [StartAppUnifiedSDK-3.0.2.jar] UNEXPECTED TOP-LEVEL EXCEPTION:
Android Pre Dex: [StartAppUnifiedSDK-3.0.2.jar] java.util.zip.ZipException: error in opening zip file
Any ideas on what might be wrong?
the error message format shows that you are not using Gradle to build. You either loaded the eclipse project file (.classpath/.project) or had some existing iml files.
This means changes to build.gradle will have no effect since Studio uses the IntelliJ internal builders instead.
You need to import your build.gradle file instead to create a new Studio project.
I created a simple .proto file and executed the compiler (protoc-2.5.0rc1-win32.zip). A java file was generated to the prescribed package. However, the generated file does not compile.
The .proto file is simple with a single message with a bunch of simple types optional fields (properly numbered).
The .java file does not compile, for example:
The constructor GeneratedMessage.FieldAccessorTable(Descriptors.Descriptor, String[]) is undefined
The method ensureFieldAccessorsInitialized(Class, Class) is undefined for the type GeneratedMessage.FieldAccessorTable
... and host of other errors along the same line (like trying to override a final method in superclass)
errors that hint at some mismatch at the level of the API version?
Any ideas?
Thanks
RESOLVED: found that the version of proto expected by the API I am using is 2.4.1 and I was using latest.
i have solved the same problem.
the answer:
1.show your protoc complier version
e.g.
D:\workspace2\monitor\src\main\resources>protoc --version
libprotoc 2.6.1
2.make the protoc jar coincident with your protoc complier version
e.g.
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.6.1</version>
</dependency>
For me, I tracked this down to akka including an older prototype buffer version, and the versions conflicted.
Solution: Check all your libraries for older versions of prototype buffer, it may be included in something you have already.
My guess is that you first need to build a new protocol buf jar ( protobuf-java-2.5.0rc1.jar ) from the source distribution protobuf-2.5.0rc1.zip and make this a local "system" dependency of your maven pom.xml. I also get compile errors if i just produce new java stubs with the new compiler but have the old 2.4.1 jar dependency in my pom. I couldnt find a maven repository which hosts the 2.5.0rc1.jar already built. If you just take the source files from the source distribution , you miss some class files like com.google.protobuf.DescriptorProtos.*.