我正在尝试使用新的Android Studio,但我似乎无法让它正常工作.
我正在使用Gson库来序列化/反序列化JSON对象.但是库不知何故不包含在构建中.
我创建了一个只有MainActivity的新项目.在/ libs文件夹中复制gson-2.2.3.jar并将其添加为库依赖项(右键单击 - >添加为库).这包括android studio中的jar,因此可以从源文件中引用它.
当我尝试运行该项目时,它无法编译,所以我添加:
compile files('libs/gson-2.2.3.jar')
Run Code Online (Sandbox Code Playgroud)
到de .gradle文件中的依赖项.之后它正确编译,但在运行应用程序时,我得到了一个ClassDefNotFoundException.
有谁知道我做错了什么?
android dependency-management gradle gson android-gradle-plugin
所以我试图将我的本地.jar文件依赖项添加到我的build.gradle文件中:
apply plugin: 'java'
sourceSets {
main {
java {
srcDir 'src/model'
}
}
}
dependencies {
runtime files('libs/mnist-tools.jar', 'libs/gson-2.2.4.jar')
runtime fileTree(dir: 'libs', include: '*.jar')
}
Run Code Online (Sandbox Code Playgroud)
你可以看到我在这里将.jar文件添加到referencedLibraries文件夹中:https://github.com/WalnutiQ/wAlnut/tree/version-2.3.1/referencedLibraries
但问题是当我运行命令时:在命令行上运行gradle我得到以下错误:
error: package com.google.gson does not exist
import com.google.gson.Gson;
Run Code Online (Sandbox Code Playgroud)
这是我的整个回购:https://github.com/WalnutiQ/wAlnut/tree/version-2.3.1
java dependency-management gradle gradle-eclipse build.gradle
我知道这个问题:将本地.aar文件添加到我的gradle构建中,但该解决方案对我不起作用.
我尝试将此语句添加到我的build.gradle文件的顶级:
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
Run Code Online (Sandbox Code Playgroud)
我还把slidingmenu.aar文件放入/libs并在dependencies部分中引用它:compile 'com.slidingmenu.lib:slidingmenu:1.0.0@aar'但它根本不起作用.
我也试过compile files('libs/slidingmenu.aar')但没有运气.
我错过了什么?有任何想法吗?
PS Android Studio 0.8.2
android android-studio build.gradle android-gradle-plugin aar
我谷歌关于本地aar,每个人都说它可以工作,但它在android studio 1.1.0不起作用.
我尝试使用:
compile fileTree(dir: 'libs', include: ['*.aar'])
Run Code Online (Sandbox Code Playgroud)
但它提示:
Warning:Project app: Only Jar-type local dependencies are supported. Cannot handle: /Users/kycq/AndroidStudioProjects/QingTaJiao/app/libs/KycqBasic-release.aar
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能使用当地的aar?如果我应该使用:
compile 'com.example.library:library:1.0.0@aar'
Run Code Online (Sandbox Code Playgroud)
这该怎么做?
我有.aar一个库模块的文件.
我想在我的其他项目的库模块中将它用作库或依赖项.
我该怎么做?
我尝试了以下链接提供的选项:http:
//kevinpelgrims.com/blog/2014/05/18/reference-a-local-aar-in-your-android-project/
它只有.aar在我的项目的应用程序模块中添加引用时才有效.但不在图书馆模块中工作.
谢谢.
android gradle android-studio build.gradle android-gradle-plugin
我有一个Android库项目FooLib.FooLib引用像Android这样Context的东西,但不需要任何资源文件(事情res/),所以我目前将其打包为JAR供我的应用程序使用.
我现在想要FooLib依赖BarLib,但BarLib 确实使用资源,所以我不能打包BarLib成JAR.相反,它被打包为AAR.我有可能FooLib依赖BarLib但继续打包FooLib成JAR吗?或者,有一个AAR依赖关系FooLib强制我使它也成为AAR吗?
我已经看到各种开发者发布的问题(Android Studio将两个.aar合并为一个和其他),但我没有看到一个明确的响应,使我能够创建一个包含一个或多个AAR或JAR的AAR(我可以使用JAR因为我不需要共享任何资源;只有类).这是我的库项目的app.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
minSdkVersion 16
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.code.gson:gson:2.1'
compile ('libs/eventbus.jar')
compile project(':core-release')
compile project(':midware-release')
}
Run Code Online (Sandbox Code Playgroud)
同样,这个应用程序是一个库项目,需要两个其他库项目('核心发布','midware-release'),虽然我能够生成一个我可以在我的应用程序中使用的AAR文件,但应用程序无法找到依赖库项目的类,我必须将两个库项目的AAR添加到我的应用程序中.
这是app.gradle应用程序项目(无需手动添加JAR),无法找到依赖项目的类:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.app.sample"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies …Run Code Online (Sandbox Code Playgroud) 我使用的是Android Studio 1.2
我创建了一个私有库,我想在另一个应用程序中使用它.
要使用它我创建一个AAR文件,但这个AAR不起作用.我的库中有一个对AAR文件的依赖.
AAR文件不依赖?
如果我使用jar,我包括创建所有依赖项,项目工作正常.
注意 :
我知道如何导入AAR文件.问题是在AAR中使用AAR ..
谢谢.
Android studio 找不到明显位于我的本地存储库中的依赖项。错误:
错误:找不到:com.poppy:tutti-frutti-dtos:1.0.0-SNAPSHOT 打开文件
在“项目结构”对话框中打开
我正在使用 gradle 包装器和 Android studio 1.0.2。我已经仔细检查了依赖项的名称,并且该项目有以下 build.gradle 文件。我也尝试过 mavenLocale() ,它似乎也不起作用。有什么调试建议吗?
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'D:/Users/Math/.m2/repository' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects{
repositories {
jcenter()
maven { url 'D:/Users/Math/.m2/repository' }
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的项目的模块 build.gradle 文件的依赖部分:
apply …Run Code Online (Sandbox Code Playgroud) 这是我的build.gradle文件.我已经按照本教程.
repositories {
mavenCentral()
jcenter()
mavenLocal()
maven {
url "${project.rootDir}/mvn-repo/release" //ADD THE CORRECT LOCATION OF THE CREATIVESDK LIBRARY FILES
}
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
packagingOptions {
exclude 'META- INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
}
defaultConfig {
applicationId "com.example.test"
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':libraries:collage-views')
compile 'com.aviary.android.feather.sdk:aviary-sdk:3.6.5'
compile 'com.adobe.creativesdk:behance:0.2.10'
compile 'com.adobe.creativesdk:image:4.0.0'
// …Run Code Online (Sandbox Code Playgroud)