I am trying to add a jar to a project on Android. I did a test with the maps.jar library. Which has a class named com.google.android.maps.MapView when i do the import of that class. I get the error package com.google.android.maps does not exist import com.google.android.maps.MapView;
I try to include this jar file in several ways into my gradle.build:
dependencies {
runtime files('/Users/user/Documents/workspace/MyAndroidApp/libs/maps.jar')
//runtime fileTree(dir: '/Users/user/Documents/workspace/MyAndroidApp/libs', include: '*.jar')
//classpath fileTree(dir: '/Users/user/Documents/workspace/MyAndroidApp/libs', include: 'maps.jar')
}
Not luck so far.
Any idea? Thanks!
Here is how i got it going:
build.gradle
file (note there are two build.gradle
files at least, dont use the root one use the one in your project scope). find the dependencies section (for me i was trying to the admob -GoogleAdMobAdsSdk jar file)
dependencies { compile files('libs/android-support-v4.jar','libs/GoogleAdMobAdsSdk-6.3.1.jar') }
last go into settings.gradle
and ensure it looks something like this:
include ':yourproject', ':yourproject:libs:GoogleAdMobAdsSdk-6.3.1'
必须将编译依赖项添加到compile
配置(而不是runtime
或class path
)。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.