I updated my android studio to version 3.3 canary 13
(latest as of this writing). I was prompted to update my project's gradle version and I updated it to version 3.3.0-alpha13
我把我的安卓工作室更新到了3.3canary 13(撰写本文时的最新版本)。系统提示我更新项目的Gradle版本,我将其更新到版本3.3.0-alpha13
classpath 'com.android.tools.build:gradle:3.3.0-alpha13'
类路径‘com.android.tools.build:gradle:3.3.0-alpha13’
Now when i tried to run my project, it failed with an error
现在,当我尝试运行我的项目时,它失败了,并出现错误
Error: Class descriptor 'Landroid/support/customtabs/ICustomTabsCallback/;' cannot be represented in dex format.
错误:类描述符‘Landroid/support/customtabs/ICustomTabsCallback/;’不能以dex格式表示。
I tried to invalidate cache, clean and rebuild the project but nothing worked. Below is my app's build.gradle
我试图使缓存失效,清理和重建项目,但都没有奏效。下面是我应用程序的build.gradle
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha3', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
}
更多回答
please double check with androidx
import . it might be causing the issue
请与androidx进口公司复核。可能是它导致了这个问题
@TejasPandya I managed to solve the problem. see answer below
@TejasPandya我设法解决了这个问题。请参阅下面的答案
I decided to try ./gradlew build --stacktrace
command and saw that ICustomTabsCallback
class is being used by androidx.browser:browser:1.0.0-rc01
library.
我决定尝试使用./gradlew Build--stacktrace命令,并看到androidx正在使用ICustomTabCallback类。Browser:Browser:1.0.0-rc01库。
> Transform browser.aar (androidx.browser:browser:1.0.0-rc01) with DexingTransform
AGPBI: {"kind":"error","text":"Class descriptor \u0027Landroid/support/customtabs/ICustomTabsCallback/;\u0027 cannot be represented in dex format.","sources":[{}],"tool":"D8"}
> Task :app:mergeExtDexDebug FAILED
AGPBI: {"kind":"error","text":"Class descriptor \u0027Landroid/support/customtabs/ICustomTabsCallback/;\u0027 cannot be represented in dex format.","sources":[{}],"tool":"D8"}
FAILURE: Build failed with an exception.
I then used ./gradlew app:dependencies
command to see if there is conflict in dependencies and i found the error.
然后,我使用./gradlew app:Dependations命令查看依赖项中是否存在冲突,然后发现了错误。
+--- androidx.appcompat:appcompat:1.0.0-rc01 -> 1.0.0 (*)
| \--- androidx.browser:browser:1.0.0-rc01
| +--- androidx.core:core:1.0.0-rc01 -> 1.0.0 (*)
| +--- androidx.annotation:annotation:1.0.0-rc01 -> 1.0.0
| +--- androidx.interpolator:interpolator:1.0.0-rc01 -> 1.0.0 (*)
| +--- androidx.collection:collection:1.0.0-rc01 -> 1.0.0 (*)
| \--- androidx.legacy:legacy-support-core-ui:1.0.0-rc01 -> 1.0.0 (*)
The above extract shows some of dependencies for debugCompileClasspath
configuration. We can see that androidx.appcompat:appcompat
contains androidx.browser:browser
as a transitive dependency.
上面的摘录显示了调试CompileClasspath配置的一些依赖项。我们可以看到androidx.appCompat:appCompat包含androidx.Browser:Browser作为传递依赖项。
androidx.appcompat:appcompat:1.0.0-rc01 -> 1.0.0
means that version 1.0.0
will be used instead of version 1.0.0-rc01
but this is not the case for androidx.browser:browser
. version 1.0.0-rc01
will be used instead of version 1.0.0
Androidx.appCompat:appCompat:1.0.0-rc01->1.0.0意味着将使用版本1.0.0而不是版本1.0.0-rc01,但androidx.Browser:Browser并非如此。将使用版本1.0.0-rc01,而不是版本1.0.0
To solve this error, i just removed the transitive dependencies by adding the below block of code in my app's build.gradle
为了解决这个错误,我只需在我的应用程序的build.gradle中添加以下代码块来删除传递依赖项
configurations {
compile.exclude group: 'androidx.browser', module: 'browser'
}
So my app's build.gradle will look like this
因此,我的应用程序的build.gradle将如下所示
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
android {
//....
}
configurations {
compile.exclude group: 'androidx.browser', module: 'browser'
}
dependencies {
// ....
}
After that, i just synced,cleaned and rebuild my project.
在那之后,我只是同步、清理和重建我的项目。
UPDATE
更新
If the answer din't solve your problem, The other option is to use android studio stable version (3.2.1 as per this writing) and gradle 3.2.1 classpath 'com.android.tools.build:gradle:3.2.1'
如果答案不能解决你的问题,另一个选择是使用Android Studio稳定版本(本文写作时为3.2.1)和Gradle 3.2.1 classpath‘com.android.tools.Build:Gradle:3.2.1’。
If anyone has had this problem with getting AndroidX to work with the Jetifier then you have a couple of options.
如果任何人在让androidX与Jetifier一起工作时遇到了这个问题,那么你有几个选择。
If you are able to update your Gradle and plugin version then you should do; this is a bug that was addressed 3.3.0 and above. You can see what combination of gradle/plugin versions you need here; https://developer.android.com/studio/releases/gradle-plugin.
如果您能够更新您的Gradle和插件版本,那么您应该这样做;这是一个已在3.3.0及更高版本中解决的错误。你可以在这里看到你需要的Gradle/插件版本的组合;https://developer.android.com/studio/releases/gradle-plugin.
In my case I was tied to Gradle 4.6 and it's highest plugin version of 3.2.1 (i'm using Unity 2017.4 LTS). In which can I applied the workaround found here by adding the following to my build.gradle file;
在我的例子中,我被捆绑在Gradle4.6上,它的最高插件版本是3.2.1(我使用的是Unity 2017.4 LTS)。在其中,我可以通过将以下内容添加到我的build.gradle文件来应用此处找到的解决方法;
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build.jetifier:jetifier-processor:1.0.0-beta02'
}
}
Credit to @TheHebrewHammer in the comments above for pointing this one out.
感谢@TheHebrewHammer在上面的评论中指出了这一点。
Try changing your theme in your styles.xml
so that it extends one of the MaterialComponents theme.
尝试更改style es.xml中的主题,使其扩展其中一个MaterialComponents主题。
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar">
Other options:
其他选项:
Theme.MaterialComponents
Theme.MaterialComponents.NoActionBar
Theme.MaterialComponents.Light
Theme.MaterialComponents.Light.NoActionBar
Theme.MaterialComponents.Light.DarkActionBar
More about this:
https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md
更多相关信息:https://github.com/material-components/material-components-android/blob/master/docs/getting-started.md
Looks like lots of us get similar errors for different reasons. In my case, I was returning null inside the key
compose function. Looked like this
看起来我们中的很多人因为不同的原因都会遇到类似的错误。在我的例子中,我在Key Compose函数中返回了NULL。看起来是这样的
key(item.id) {
if (shouldNotBeVisible) {
return null
}
}
Oversimplified but you get the idea. Found about this doing ./gradlew build --stacktrace
as recommended above, and the stacktrace pointed to the composable function with the issue.
过于简单化了,但你明白其中的意思。发现了这样做。/gradlew构建--上面推荐的堆栈跟踪,堆栈跟踪指向有问题的可组合函数。
更多回答
That's not a valid solution, if you are actually using customtabs.
如果您实际使用的是定制选项卡,那么这不是一个有效的解决方案。
@Marius I'm not using customtabs. As you can see, it's in the library androidx.browser:browser
which is a transitive dependency of androidx.appcompat:appcompat
library
@Marius我没有使用定制标签。如您所见,它位于androidx.Browser:Browser库中,这是androidx.appCompat:appCompat库的传递依赖项
@AdamHurwitz My app is also connecting to the network and I'm able to make back-end calls. I haven't experienced such kind of error. maybe it's related to something else but I'm glad you found a way out of the problem.
@AdamHurwitz我的应用程序也可以连接到网络,我可以进行后端呼叫。我还没有经历过这样的错误。也许这与其他事情有关,但我很高兴你找到了解决问题的方法。
@AdamHurwitz I'm going to try the other solution first. I'll let you know if it didn't work and mad a new SO.
@AdamHurwitz我要先尝试另一种解决方案。如果不起作用,我会让你知道的,然后再发一封新的信。
Like @AdamHurwitz said, this isn't a valid answer as you're removing a transitive dependency which might break the library you're relying on. This is a bug with the AGP 3.3.0-alpha13, see issuetracker.google.com/issues/117145286
就像@AdamHurwitz说的那样,这不是一个有效的答案,因为您正在移除一个可能会破坏您所依赖的库的可传递依赖项。这是agp 3.3.0-alpha13的错误,请参阅Issuetracker.google.com/Issues/117145286
我是一名优秀的程序员,十分优秀!