1、Android Studio3.0以上,gradle.build中dependencie依赖由compile变为implementation 错误:
Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
在App的build gradle 中:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile project(':SlidingMenulibrary')
}
将红色中的compile 改为
implementation project(':SlidingMenulibrary')
2、Error:Could not find com.android.tools.build:gradle:3.1.2
问题原因:在以前的工程或则App 的bulid gradle 中
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
build.gradle 用的是 mavenCentral(); 而maven 中只有最高2.3.0
没有所需的2.3.3,所以,解决办法是:
不用mavenCentral , 改为用:jcenter(), 如下图:
buildscript {
repositories {
//mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
最后问题解决。
3、
错误:Program type already present: android.support.v4.app.BackStackRecord$Op
错误:Program type already present: android.support.v4.app.ActionBarDrawerToggle$Delegate
两个错误的大致意思就是 前边已经存在了v4包的类文件。
看了一些博友的博客,发现我在配置
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
implementation 'com.google.code.gson:gson:2.3.1'
implementation project(':library-pulltorefresh')
implementation 'com.mcxiaoke.volley:library:1.0.16'
implementation project(':library-sidedrawer')
implementation project(':library-circleimageview')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation project(':library-slidingmenu')
implementation 'com.baoyz.swipemenulistview:library:1.3.0'
implementation 'org.greenrobot:eventbus:3.0.0'
}
的时候 少了一个v4的导入(不加这个导入的话 ) 下面这行会报红线,但是不影响程序运行
implementation 'com.android.support:appcompat-v7:27.1.1' 或则
implementation 'com.android.support:support-v4:27.1.1'
加上这句话之后,以上问题 迎刃而解。
自己遇到,原因跟上面一样
Program type already present: android.support.v4.app.ActionBarDrawerToggle$SlideDrawable
Message{kind=ERROR, text=Program type already present: android.support.v4.app.ActionBarDrawerToggle$SlideDrawable, sources=[Unknown source file], tool name=Optional.of(D8)}
我的配置:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':SlidingMenulibrary')
}
在Android Studio 中:解决方法:
点击菜单File -> Project Structure -> 弹出Moudle 管理窗口,
找到Dependencies - > 点击加号,增加App Modules 的v4 包,如下图:
5、org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed;
Caused by: org.gradle.api.internal.tasks.compile.CompilationFailedException: Compilation failed; see the compiler error output for details.
将所有的compile变为implementation 后,clean和rebuild都没有发现错误
6、错误: 程序包org.apache.http.protocol不存在
解决方法:
在app 工程中的build.gradle
在buildToolsVersion下边
defaultConfig上边
添加如下代码
useLibrary 'org.apache.http.legacy'
6. Failed to load AppCompat ActionBar with unknown error.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
</style>
to:
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
</style>
7.intellij idea 报 Stub index points to a file without PSI
解决方法:
File
> Invalidate Caches/Restart > Invalidate and Restart