Gradle对我和新的Android开发人员都有点困惑.任何人都可以解释Android Studio中的gradle是什么以及它的目的是什么?为什么Gradle包含在Android Studio中?
build-automation gradle android-studio android-gradle-plugin
如何将库项目(如Sherlock ABS)添加到Android Studio?
(不是旧的基于Eclipse的ADT捆绑包,而是新的Android Studio.)
更新到android studio 2.3后,我收到此错误消息.我知道这只是一个暗示,因为应用程序正常运行,但它真的很奇怪.
所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃).找到的版本25.1.1,24.0.0.示例包括com.android.support:animated-vector-drawable:25.1.1和com.android.support:mediarouter-v7:24.0.0
我的朋友:
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'
    })
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.1.1'
    compile 'com.android.support:support-v4:25.1.1'
    compile 'com.android.support:design:25.1.1'
    compile 'com.android.support:recyclerview-v7:25.1.1'
    compile 'com.android.support:cardview-v7:25.1.1'
    compile 'com.google.android.gms:play-services-maps:10.2.0'
    compile 'com.google.android.gms:play-services:10.2.0'
    compile 'io.reactivex.rxjava2:rxjava:2.0.1'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'com.jakewharton:butterknife:8.4.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
    compile 'com.blankj:utilcode:1.3.6'
    compile 'com.orhanobut:logger:1.15'
    compile 'com.facebook.stetho:stetho:1.4.2'
    provided 'com.google.auto.value:auto-value:1.2'
    annotationProcessor 'com.google.auto.value:auto-value:1.2'
    annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.5'
    compile 'com.mikepenz:iconics-core:2.8.2@aar'
    compile('com.mikepenz:materialdrawer:5.8.1@aar') { transitive = true }
    compile 'com.mikepenz:google-material-typeface:2.2.0.3.original@aar'
    compile 'me.zhanghai.android.materialprogressbar:library:1.3.0'
    compile 'com.github.GrenderG:Toasty:1.1.1'
    compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.8.0'
    compile 'com.github.MAXDeliveryNG:slideview:1.0.0'
    compile 'com.facebook.fresco:fresco:1.0.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.google.maps.android:android-maps-utils:0.4.4' …我有Android Studio Beta.我创建了一个新项目,编译我的旧模块,但是当我尝试启动应用程序时,它没有启动消息:
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException:无法合并dex
但我不知道如何解决这个错误.我用谷歌搜索了几个小时但没有成功.
我的项目是:
    // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-beta6'
        classpath "io.realm:realm-gradle-plugin:3.7.1"
        classpath 'com.google.gms:google-services:3.1.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
        google()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}
我的应用程序gradle:
    apply plugin: 'com.android.application'
android …查看文档http://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html,我们可以看到<scope>标签下<dependency> 
那是什么以及我们如何使用它来运行测试?
将Android Studio从Canary 3更新为Canary 4后,在构建时抛出以下错误.
Android依赖项'com.android.support:support-support-v4'具有不同版本的编译(25.2.0)和运行时(26.0.0-beta2)类路径.您应该通过DependencyResolution手动设置相同的版本.
我在整个项目中进行了完整的搜索,并且版本25.1.0没有使用.
APP-的build.gradle
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
defaultConfig {
    applicationId "com.xxx.xxxx"
    minSdkVersion 14
    targetSdkVersion
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
buildTypes {
    debug {
        debuggable true
    }
    release {
        debuggable false
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    lintOptions {
        abortOnError false
    }
}}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation project(':core')
implementation com.google.android.gms:play-services-gcm:9.0.0'
implementation('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
    transitive = true
}
implementation 'com.android.support:multidex:1.0.1'
implementation …我是Android App Development的新手.当我尝试创建一个新项目时,Android Project ...弹出以下消息..
错误:任务':app:preDebugAndroidTestBuild'的执行失败.
与项目':app'中的依赖'com.android.support:support-annotations'冲突.app(26.1.0)和测试app(27.1.1)的已解决版本有所不同.有关详细信息,请参阅https://d.android.com/r/tools/test-apk-dependency-conflicts.html.信息:Gradle任务[:app:generateDebugSources,:app:generateDebugAndroidTestSources,:app:mockableAndroidJar]
这是我项目的截图 点击这里查看我得到的错误的截图
我也尝试将此代码添加到我的依赖项中.androidTestCompile'com.android.support:support-annotations:23.3.0'这没有用.我也尝试了27.1.1和26.1.0 ..但也没有成功.
我的应用程序工作正常,直到我尝试添加库.添加库后,Android Studio会出现以下错误:
错误:(26)在包'inf ..'中找不到属性'layout_behavior'的资源标识符
这是我的build.gradle文件:
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.ogaclejapan.smarttablayout:utils-v4:1.3.0@aar'
    compile 'com.ogaclejapan.smarttablayout:library:1.3.0@aar'
    compile 'com.jpardogo.materialtabstrip:library:1.1.0'
    // compile 'com.lorentzos.swipecards:library:1.0.9@aar'
    compile 'com.android.support:cardview-v7:21.0.3'
    compile 'com.android.support:recyclerview-v7:21.0.3'
    compile 'com.melnykov:floatingactionbutton:1.3.0'
    compile project(':swipelib')
}
这是导致错误的xml:
 <android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
我尝试了以下方法:
但是,错误仍然存在.我该如何解决这个问题?
我正在使用Android Studio和外部Android SDK.我已经安装了支持库和支持库.支持存储库位于:
~/Development/Tools/android/sdk/extras/android/m2repository
当我向build.gradle文件中的支持库添加依赖项时,例如:
...
repositories {
    mavenCentral()
}
...
dependencies {
   compile "com.android.support:support-v4:18.0.+"
}
Android Studio找不到支持库(无法解析符号等),Gradle也找不到库:
Gradle: A problem occurred configuring project ':TestAndroidStudio'.
> Failed to notify project evaluation listener.
   > Could not resolve all dependencies for configuration ':TestAndroidStudio:_DebugCompile'.
      > Could not find any version that matches com.android.support:support-v4:18.0.+.
        Required by:
            TestAndroidStudio:TestAndroidStudio:unspecified
如何在Android Studio和/或build.gradle文件中指定Android支持存储库的位置?
android gradle android-support-library android-studio android-gradle-plugin

我正在尝试将CardView添加到我的活动中作为官方样本.但它不起作用.
如果我直接运行我的项目,它将导致java.lang.ClassNotFoundException:android.support.v7.widget.CardView.