GeezerVison is showing github.com — Can't run app when add Cloud vision to gradle · Issue #552 · GoogleCloudPlatform/java-docs-samples
Can't run app when add Cloud vision to gradle #552Labels type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. DescriptionHi all,
I have issus with google Cloud vision API , when i add to gradle then can't run app.
My gradle:
dependencies {
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.android.support:design:25.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:cardview-v7:25.0.1'
compile('com.google.cloud:google-cloud-translate:0.9.3-alpha') {
exclude group: 'io.grpc', module: 'grpc-all'
exclude group: 'com.google.protobuf', module: 'protobuf-java'
exclude group: 'com.google.api-client', module: 'google-api-client-appengine'
}
compile('com.google.apis:google-api-services-translate:v2-rev47-1.22.0') {
exclude group: 'com.google.guava'
}
compile 'com.google.api-client:google-api-client-android:1.20.0' exclude module: 'httpclient'
compile group: 'com.google.cloud', name: 'google-cloud-vision', version: '0.9.3-alpha'
}
and I got a message :
Error:trouble processing "javax/transaction/HeuristicCommitException.class":
Error:Ill-advised or mistaken usage of a core class (java.* or javax.*)
Error:when not building a core library.
Error:This is often due to inadvertently including a core library file
Error:in your application's project, when using an IDE (such as
Error:Eclipse). If you are sure you're not intentionally defining a
Error:core class, then this is the most likely explanation of what's
Error:going on.
Error:However, you might actually be trying to define a class in a core
Error:namespace, the source of which you may have taken, for example,
Error:from a non-Android virtual machine project. This will most
Error:assuredly not work. At a minimum, it jeopardizes the
Error:compatibility of your app with future versions of the platform.
Error:It is also often of questionable legality.
Error:If you really intend to build a core library -- which is only
Error:appropriate as part of creating a full virtual machine
Error:distribution, as opposed to compiling an application -- then use
Error:the "--core-library" option to suppress this error message.
Error:If you go ahead and use "--core-library" but are in fact
Error:building an application, then be forewarned that your application
Error:will still fail to build or run, at some point. Please be
Error:prepared for angry customers who find, for example, that your
Error:application ceases to function once they upgrade their operating
Error:system. You will be to blame for this problem.
Error:If you are legitimately using some code that happens to be in a
Error:core package, then the easiest safe alternative you have is to
Error:repackage that code. That is, move the classes in question into
Error:your own package namespace. This means that they will never be in
Error:conflict with core system classes. JarJar is a tool that may help
Error:you in this endeavor. If you find that you cannot do this, then
Error:that is an indication that the path you are on will ultimately
Error:lead to pain, suffering, grief, and lamentation.
Error:1 error; aborting
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex '/Users/thanhlv10/.gradle/caches/modules-2/files-2.1/javax.transaction/transaction-api/1.1/2ca09f0b36ca7d71b762e14ea2ff09d5eac57558/transaction-api-1.1.jar' to '/Users/thanhlv10/Documents/Android/workspace/LeanVocabularyEnglish/app/build/intermediates/transforms/dex/debug/folders/1000/10/transaction-api-1.1_08247d5a5ad76d54ec97f25b2765cc9d2ddbcc67'
Plz tell me know if you have any solution.
Thanks Activitychanged the title [-]Can't run app when app Cloud vision to gradle[/-] [+]Can't run app when add Cloud vision to gradle[/+] on Mar 7, 2017added type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. on Mar 8, 2017gguuss commented on Mar 13, 2017 Are you trying to use Vision from Android?
You might want to try starting from the Cloud vision Android sample as opposed to the Cloud client library sample referenced here. suntzu93 commented on Mar 14, 2017 Yes, I tried Cloud vision Android sample and it's working but when I generate a APK , I got a message .
Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/common/annotations/Beta.class
I'm thinking "Cloud vision Android sample" and " com.google.cloud:google-cloud-translate:0.9.3-alpha " is Conflicts .
My gradle :
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:design:25.0.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile('com.google.cloud:google-cloud-translate:0.9.3-alpha') {
exclude group: 'io.grpc', module: 'grpc-all'
exclude group: 'com.google.protobuf', module: 'protobuf-java'
exclude group: 'com.google.api-client', module: 'google-api-client-appengine'
}
compile('com.google.apis:google-api-services-translate:v2-rev47-1.22.0') {
exclude group: 'com.google.guava'
}
compile 'com.google.http-client:google-http-client-gson:1.22.0' exclude module: 'httpclient'
compile 'com.google.apis:google-api-services-vision:v1-rev22-1.22.0'
compile 'com.google.android.gms:play-services-ads:10.0.1'
compile 'com.android.volley:volley:1.0.0'
} MuhammadMuzammilQadri commented on Mar 14, 2017 Why is it not working with Cloud client library but with the android sample? All the documentation on Vision is about the client library.. I'm facing below error when adding
dependency {
compile "com.google.cloud:google-cloud-vision:0.9.4-beta"
}
in the project:
Error:trouble processing "javax/transaction/HeuristicCommitException.class":
Error:Ill-advised or mistaken usage of a core class (java.* or javax.*)
Error:when not building a core library.
Error:This is often due to inadvertently including a core library file
Error:in your application's project, when using an IDE (such as
Error:Eclipse). If you are sure you're not intentionally defining a
Error:core class, then this is the most likely explanation of what's
Error:going on.
Error:However, you might actually be trying to define a class in a core
Error:namespace, the source of which you may have taken, for example,
Error:from a non-Android virtual machine project. This will most
Error:assuredly not work. At a minimum, it jeopardizes the
Error:compatibility of your app with future versions of the platform.
Error:It is also often of questionable legality.
Error:If you really intend to build a core library -- which is only
Error:appropriate as part of creating a full virtual machine
Error:distribution, as opposed to compiling an application -- then use
Error:the "--core-library" option to suppress this error message.
Error:If you go ahead and use "--core-library" but are in fact
Error:building an application, then be forewarned that your application
Error:will still fail to build or run, at some point. Please be
Error:prepared for angry customers who find, for example, that your
Error:application ceases to function once they upgrade their operating
Error:system. You will be to blame for this problem.
Error:If you are legitimately using some code that happens to be in a
Error:core package, then the easiest safe alternative you have is to
Error:repackage that code. That is, move the classes in question into
Error:your own package namespace. This means that they will never be in
Error:conflict with core system classes. JarJar is a tool that may help
Error:you in this endeavor. If you find that you cannot do this, then
Error:that is an indication that the path you are on will ultimately
Error:lead to pain, suffering, grief, and lamentation.
Error:1 error; aborting
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException
gguuss commented on Mar 15, 2017 I'm currently not testing the Cloud Client library approach with Android. I'll see if I can come up with a working solution for you. gguuss commented on Mar 16, 2017 suntzu93 commented on Mar 16, 2017 @gguuss Could you explain my error ? gguuss commented on Mar 16, 2017 Your error is occurring because the Cloud library has dependencies that conflict with core Android services.
Even if you ignore the error by passing the flag in your Application gradle file, e.g.:
dexOptions {
preDexLibraries = false
additionalParameters=['--core-library']
}
which seems like a bad idea, you will need to figure out a way to authorize the library by building a custom credential object because the Cloud library is tightly coupled to default application credentials. It would probably be easier if you built a microservice or other backend for accessing the Cloud Vision API.
The Cloud client libraries aren't tailored to Android, which is why there is a separate vision library for Android. If you use the Android library, there are benefits such as an offline vision model. suntzu93 commented on Mar 17, 2017 Thank you for your answer , so i understood that now we have no Cloud client for Android and waiting until Google provide a version for android ? gguuss commented on Mar 17, 2017 @thanhlv93 Correct, the Cloud client library does not explicitly support Android but it does work from Gradle. If I come up with a solution to authenticating the client library on Android, I'll be sure to share it. If you can get it to work, please let us know! suntzu93 commented on Mar 18, 2017 nnegrey commented on Dec 5, 2018 This appears to have been resolved. Please feel free to reopen if this is not true. :)
MetadataMetadatatype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. DevelopmentNo branches or pull requestsIssue actions
|