I'm trying to put together a wearable app and I keep encountering the error Didn't find class "android.support.v4.view.GridViewPager". I'm also using android studio 1.0, and I can't find where to add a java build path. Here's what I have:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:20.0.0'
compile 'com.google.android.support:wearable:1.0.0'
compile 'com.google.android.gms:play-services-wearable:6.1.71'
compile files('libs/support-v4-20.0.0-javadoc.jar')
}
I've looked around at a lot of problems similar to this, and most involve the support library. I have the support library installed and in my libs folder in the wear portion of my app, and I still get this error. Can anyone help?
if you want to use GridViewpager for wear you probably need
android.support.wearable.view.GridViewPager not android.support.v4.view.GridViewPager
Related
I have created minimal project based on official tutorial https://kotlinlang.org/docs/reference/mpp-create-lib.html
Gradle build produces .jar file which looks good (stream-api-lib-jvm-1.0-SNAPSHOT.jar)
But when I include this jar (manually) into my Android Studio project, it cannot find the classes (Invalidating cache already tried).
Gradle config changes for adding the lib (into app/libs)
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/stream-api-lib-jvm-1.0-SNAPSHOT.jar')
Finally found the reason: in my case kotlin file in library which I tried to access, did not have the "package" directive on top.
I have class libraries I've developed in Netbeans, for java native applications. I would like to use this functionalities in Android app project, instead of writing the whole code again.
I know how to create Jar in netbeans and add it as a dependency(or even a separate module) in the android project.
but it seems I cannot use the code when I call the related function explicitly.
Let's say I have the following Scheme in Netbeans:
CommonLogicLayer (Class Library)
--->SourcesPackages
---><default package>
--->FileTest
Inside fileTest.java I have function named: Test(String fullPath) that gets the path of a file and print its content. very simple.
After building the library (for Jar file), I insert the jar in libs folder, compile the android app, and in onCreate function I tried to call the jar like that:
CommonLogicLayer.FileTest.Test("c:\\text.txt")
Even though, the builder (Gradle File) add CommonLogicLayer as a dependency:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile project(':utilitiesandroid')
compile project(':commonutilities')
compile project(':CommonLogicLayer')
}
I cannot use its functions as I desire.
I also tried adding the jar as a Module, and add this module as a dependency, but still no results.
So my question is:
Can Android studio has java native libraries that are not (android studio/Eclipse)
If 1 is 'Yes', what am I doing wrong?
If 1 is 'No', what is the work around for it instead of replicate the code?
Much Obliged!
I've use Kryo libs and it's pretty good. However, when I want to create a signed APK, it keeps failing to build because of the error:
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
java.io.IOException: Can't write [C:\AndroidProjects\App\app\build\intermediates\transforms\proguard\release\jars\3\1f\main.jar] (Can't read [C:\AndroidProjects\App\app\importLibs\minlog-1.3.0.jar(;;;;;;**.class)] (Duplicate zip entry [minlog-1.3.0.jar:com/esotericsoftware/minlog/Log$Logger.class]))
build gradle (module app)
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-ads:9.4.0'
compile 'com.android.support:design:24.1.1'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile files('importLibs/kryo-2.23.0.jar')
compile files('importLibs/minlog-1.3.0.jar')
compile files('importLibs/objenesis-2.1.jar')
compile files('importLibs/reflectasm-1.10.1-shaded.jar')
}
proguard file
proguard-rules.pro
-dontwarn com.esotericsoftware.**
-dontwarn org.objenesis.**
-keep class com.esotericsoftware.**{*;}
What exactly do I need to write to make it work?
There can be case where a library is part of another library that you have imported in your project
Check the lib dependency tree using following command
For Android, use this line
gradle app:dependencies
or if you have a gradle wrapper:
./gradlew app:dependencies
Or else there is a less popular Android studio plugin called GradleView that can give you entire lib tree used in your application and also where it might be clashing with some other library.
I had similar problem, and I solved it with just including retrofit:
'com.squareup.retrofit:retrofit:1.9.0'
I hope it will help you too.
So I have an executable Android project, it runs and works well.
I have made a library for it, separate project, only using java, not Android framework.
No I would like to make a .jar from my library and add it to my Android Proejct.
I have made it so far, but when I run it I get the following error:
in short:
Caused by: com.android.dx.cf.iface.ParseException: bad class file
magic (cafebabe) or version (0034.0000)
In long.
I have added the .jar dependency to my gradle file: (It is the task_server_core.jar)
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile files('libs/task_server_core.jar')
compile 'com.android.support:appcompat-v7:21.+'
}
And both projects made with java 1.8.0_45
What m I doing wrong?
Changed both Android project's and java lib project's JAVA version to 1.7 solved the problem.
I'm doing the beginner android course on udacity and the code that they make you put in the MainActivity.java file is full of errors and keeps saying build failed in the console. Here is a link to a screenshot of android studio after failed build
http://postimg.org/image/6etcu6ldz/
I think support library is missing.
Go to your build.gradle (Module:app) and check if support library is in dependencies section.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.+'
}
In addition, you have to install it in SDK Manager.
I hope this answer will help you!