gpt4 book ai didi

android - 将项目从 Android Studio 版本 2 转换为 3- 配置问题

转载 作者:行者123 更新时间:2023-12-03 05:41:58 32 4
gpt4 key购买 nike

我对 android 项目的配置有问题。我将 Android Studio [AS] 从 v2 升级到 v3 并遇到了很多问题。我在文档中更改了 gradle:
gradle-wrapper,gradle 插件版本,存储库 google 或 jcenter 而不是 maven。请看配置:
我有一个名为 mytwayapp 的项目,它有 build.gradle:

  buildscript {
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
//{ url "http://jcenter.bintray.com/" }
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
google()
jcenter()
}
}

dependencies {
implementation project(':app')
}

接下来我有一个名为 app 的模块,带有 build.gradle:
apply plugin: 'com.android.application'


android {
compileSdkVersion 23
buildToolsVersion '27.0.3'
// buildToolsVersion "26.0.2"

defaultConfig {
applicationId "com.mytway.activity.registerformactivity"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
preDexLibraries = false;
javaMaxHeapSize "2g"
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/res/assets/fonts'] } }

testOptions {
unitTests.returnDefaultValues = true
}

lintOptions {
abortOnError false
}


}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.gms:play-services:8.4.0'
implementation 'com.android.support:appcompat-v7:23.1.1'
implementation 'com.android.support:support-v4:23.1.1'
implementation 'com.android.support:support-v13:23.1.1'
implementation 'joda-time:joda-time:2.9.4'
implementation files('../libs/MPAndroidChart-v3.0.1.jar')

//to remove when Dex is over memory
testImplementation group: 'org.powermock', name: 'powermock-api-easymock', version: '1.6.6'
testImplementation 'org.powermock:powermock-mockito-release-full:1.5.4'
testImplementation 'org.powermock:powermock-api-mockito:1.6.6'
testImplementation 'org.powermock:powermock-module-junit4:1.5.1'
testImplementation 'org.mockito:mockito-all:1.9.5'
testImplementation 'org.powermock:powermock-mockito-release-full:1.6.1'
testImplementation 'org.easymock:easymock:3.1'
// testCompile files('build/lib/powermock-easymock-1.6.6-full.jar')
testImplementation 'junit:junit:4.12'
}

接下来是 gradle-wrapper:
#Thu Mar 16 20:14:22 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

问题:
我无法与 gradle 同步,如果我尝试则错误:
无法初始化类 com.android.tools.idea.gradle.eclipse.GradleImport

当我尝试从 cmd 安装时,然后:
./gradlew install -x test

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\android\BitBucket\mytwayapp\build.gradle' line: 22

* What went wrong:
A problem occurred evaluating root project 'mytwayapp'.
> Could not find method implementation() for arguments [project ':app'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s

这意味着问题在于主 build.gradle 依赖于“:app”,但它看起来不错。
我尝试刷新、重建、无效、重新启动,但仍然有问题。
项目结构看起来很奇怪,这里是一个屏幕:
enter image description here

enter image description here

回答:
下面的提示不起作用,我将 Android Studio 从 3.4 降级到 3.1,并在进行一些修饰后对其进行编译。谢谢你的时间。

最佳答案

尝试更新到最新版本:

dependencies {
classpath 'com.android.tools.build:gradle:x.x.x'
}

buildToolsVersionbuild.gradle

关于android - 将项目从 Android Studio 版本 2 转换为 3- 配置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52407703/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com