【问题标题】:cannot resolve symbol 'chromium'无法解析符号“铬”
【发布时间】:2018-09-06 04:20:12
【问题描述】:

我正在尝试使用受信任的网络活动,遵循本指南:https://developers.google.com/web/updates/2017/10/using-twa

我确实按照所有步骤进行了操作,但是有几个单词 Android Studio 无法自行解决,我没有找到任何解决方案。主要问题似乎是 org.chromium 。

无法解析的粗体字:

在 TwaSessionHelper.java 中:

import org.chromium.customtabsclient.shared.ServiceConnection;

import org.chromium.customtabsclient.shared.ServiceConnectionCallback;

...

公共类 TwaSessionHelper 实现 ServiceConnectionCallback {

...

mConnection = new ServiceConnection(this);

在 TwaLauncherActivity.java 中:

setContentView(R.layout.activity_twa_launcher);

在几行代码中:

TwaSessionHelper.TwaSessionCallback twaSessionCallback = mTwaSessionCallback.get();

我错过了什么?

这是我的 build.gradle 文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "didi.a8bitpocketwrestlers"
        minSdkVersion 17
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.+'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.android.support:customtabs:28.+'
}

【问题讨论】:

  • 您是否像示例应用程序那样导入了库com.android.support:customtabs?请更新您的问题并显示您的 gradle 文件。

标签: java android-studio trusted-web-activity


【解决方案1】:

Android Studio 无法解析 ServiceConnectionCallback 类,因为 com.android.support:customtabs 库不包含/提供它。此类仅存在于 this GitHub repository 中,并且没有任何 maven 存储库。所以你不能在 build.gradle 文件中添加对它的依赖,你必须下载它并手动将它添加到你的项目中。

this GitHub repository只下载shared目录,add it in your project as a module

在您的应用程序 build.gradle 文件中添加对 shared 模块的依赖项。

compile project(':shared')

【讨论】:

  • 谢谢,差不多解决了。但它仍然无法解析 mTwaSessionCallback。
  • 你的班级有这个字段吗?私有 WeakReference mTwaSessionCallback;
猜你喜欢
  • 2018-11-11
  • 1970-01-01
  • 1970-01-01
  • 2021-02-04
  • 2016-12-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多