Installing/Using J2V8 in Android Studio - android

I am new to Android Studio development, as well as gradle and j2v8.
I have a sample Hello World app and want to use j2v8 in it (just for curiosity). I have the following in my application gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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:24.2.1'
testCompile 'junit:junit:4.12'
// https://mvnrepository.com/artifact/com.eclipsesource.j2v8/j2v8_android
compile group: 'com.eclipsesource.j2v8', name: 'j2v8_android', version: '3.0.5'
}
The last one in there is my attempt at adding j2v8.
Next I tried a sample line from this post, so I added the following to my Activity:
V8 v8 = V8.createV8Runtime();
What I don't understand is what imports I need for that to work. I must be missing one or more steps but had a hard time finding instructions online.
Thanks.

using compile group: 'com.eclipsesource.j2v8', name: 'j2v8_android', version: '3.0.5' , add import com.eclipsesource.v8.V8 also not work.
change to using compile 'com.eclipsesource.j2v8:j2v8_android:3.0.5#aar' works fine.

My own solution:
download 3.0.5 aar file from here
Add as a module via Android studio following these directions

Related

Android libraries: versions conflict issue

I've the below dependence in my Android app build.gradle
compileSdkVersion 25
buildToolsVersion "25.0.2"
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.6.0'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
compile 'com.google.firebase:firebase-ads:10.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:multidex:1.0.1'
}
but getting an error about versions compatibility, as shown below, what is the one to be changed here, i could not figure it out :(
I had same problem what i did was compile the higher version of libraries ,which were creating this error,in app:gradle only.
for example in your case
compile 'com.android.support:mediarouter-v7:25.0.0'
Add this in app:gradle.
There may be more like this mediarouter libraries if it still give error add them jst like this(making them higher version).
First you need to find out where's what consists of a conflicting version of the library. The easiest way to do so is to:
Open Terminal pane in your Android Studio.
Type in: ./gradlew androidDependencies
Find the row that represents the ENCLOSING library consisting of a conflict.
Then just use exclude statement for the conflicting library, like so:
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
(the example assuming com.android.support.test.espresso:espresso-core:2.2.2 was the ENCLOSING library, and com.android.support:support-annotations being the conflict)

Unable to use Snackbar after updating Android Studio

I have recently updated my Android Studio version to 2.3
I am working on a project now and I've noticed that I am unable to import Snackbar class. I never had that problem before.
I can use it by adding compile 'com.nispok:snackbar:2.6.1' and I can import it then, but I don't think I should have to do that instead of just using Android's android.support.design.widget.Snackbar;
This is are my dependencies from build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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.2.0'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
I have also tried to play around with DataBinding concept in my project but I don't think this could cause that issue?
Thank you.
You are missing the compile 'com.android.support:design:25.2.0' in your dependencies. As the library is not added you are unable to get the Snackbar class.

Android Studio: canot import com.google.android.youtube

I got the jar file and also pasted it in lib folder of my project. Got the API key , and also wrote compiling code but still cannot import com.google.android.youtube
dependencies {
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile files('libs/YouTubeAndroidPlayerApi.jar')
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.1.0'
compile 'com.android.support:design:25.1.0'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-vision:10.0.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.google.android.gms:play-services-places:10.0.1'
compile 'com.google.apis:google-api-services-youtube:v3-rev157-1.21.0'
}
The dependency: compile files('libs/YouTubeAndroidPlayerApi.jar') have two occurrences in your gradle file. Also edit the dependency: compile 'com.google.apis:google-api-services-youtube:v3-rev157-1.21.0' to compile 'com.google.apis:google-api-services-youtube:v3-rev181-1.22.0'. You can find more information here. After updating the gradle file, build your project once again.
I found here an issue about Android Player API of YouTube. The issue is all about YouTube APIs should have support via gradle and a documentation of it. I found here in this issue that one of the community created a github on how to add YouTube Android Player API into Android application via Gradle. So you may look on this on how to use it.
For more information, check this related SO question.

Gradle build stuck while using symja library

Gradle build is stuck while running project.
I have included symja-2015-08-09.jar file in libs folder.
I have no other dependencies and no other external jar files.
Can anyone please suggest any solution.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
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:24.2.1'
testCompile 'junit:junit:4.12'
}
The app runs fine after removing the jar file.
Has anyone used symja libraries in their android projects before?
You can try, clean the project then rebuild it. It may work. But first of all make sure you have installed proper android SDK

AppCompat Error onCreate()

I just imported my project which worked fine from Eclipse to Android Studio v1.2.11 and now the project is no longer working with the following error which make the app crashes at onCreate() method:
java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV11.
I have updated updated my app to the latest v7 library, i.e. 22.1.1. below is my gradle.build dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.android.support:support-v4:19.1.0') {
force = true
}
compile('com.google.android.gms:play-services-base:7.3.0') {
force = true
}
compile 'com.google.android.gms:play-services-plus:7.3.0'
compile 'joda-time:joda-time:2.7'
compile 'com.google.http-client:google-http-client-gson:1.20.0'
compile 'com.parse.bolts:bolts-android:1.1.2'
compile('com.facebook.android:facebook-android-sdk:3.22.0#aar') {
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'bolts'
}
compile 'com.google.guava:guava:18.0'
compile project(':PullToRefreshListView')
compile project(':CircularImageView')
compile project(':CountryPicker')
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:support-v13:22.1.1'
}
configurations {
// to avoid double inclusion of support libraries
all*.exclude group: 'com.android.support', module: 'support-v4'
}
NB: I am using Theme.AppCompat.Light in my styles which I believe supports ActionBar. What I want to achieve is the Nav. drawer but the app doesn't go past the onCreate(). Any help with this exception will be highly appreciated
For anyone having similar issue, I was able to solve this and thought I should share with others. The error was due to my configuration as I was excluding the android.support in my project. Once I commented it, it just vanished.
Make sure your class dependency is in your application specific build.gradle file, not your global build.gradle file.

Categories

Resources