小编a_l*_*ody的帖子

java.lang.IllegalAccessError:类 org.jetbrains.kotlin.kapt3.base.KaptContext Android

我已经收到这样的错误好几天了,但我找不到解决方案。你能帮我么?

问题可能是由什么引起的?

错误 :

java.lang.IllegalAccessError: class org.jetbrains.kotlin.kapt3.base.KaptContext (in unnamed module @0x6acdb135) cannot access class com.sun.tools.javac.util.Context (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.util to unnamed module @0x6acdb135
    at org.jetbrains.kotlin.kapt3.base.KaptContext.<init>(KaptContext.kt:28)
    at org.jetbrains.kotlin.kapt3.KaptContextForStubGeneration.<init>(KaptContextForStubGeneration.kt:40)
    at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.contextForStubGeneration(Kapt3Extension.kt:287)
    at org.jetbrains.kotlin.kapt3.AbstractKapt3Extension.analysisCompleted(Kapt3Extension.kt:171)
    at org.jetbrains.kotlin.kapt3.ClasspathBasedKapt3Extension.analysisCompleted(Kapt3Extension.kt:102)
    at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$invokeExtensionsOnAnalysisComplete(TopDownAnalyzerFacadeForJVM.kt:112)
    at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:122)
    at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:86)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:252)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler$analyze$1.invoke(KotlinToJVMBytecodeCompiler.kt:243)
    at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:113)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:243)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:90)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:56)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:169)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:92)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
    at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:412)
    at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:112)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:358)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally$default(IncrementalCompilerRunner.kt:300)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl$rebuild(IncrementalCompilerRunner.kt:119)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:170)
    at …
Run Code Online (Sandbox Code Playgroud)

java android kotlin kapt

50
推荐指数
3
解决办法
4万
查看次数

Android 清单 POST_NOTIFICATIONS 缺少导入

尝试实现 android 13 或“提拉米苏”的通知权限,但未能获得该权限的导入。

目前:目标SDK版本是32 编译SDK版本是32

我也在清单中声明了它,如下所示:

 <uses-permission android:name="android.permission.POST_NOTIFICATIONS"
Run Code Online (Sandbox Code Playgroud)

导入我正在使用:

import android.Manifest
Run Code Online (Sandbox Code Playgroud)
  • 但即使在我的片段中也没有导入。

在此输入图像描述

java android kotlin android-permissions android-studio

45
推荐指数
4
解决办法
3万
查看次数

尝试在 Android 库中使用 Room,但找不到方法 ksp()(Kotlin 符号处理)

我正在按照android 开发人员教程来实现本地房间数据库。

我目前正在进行安装,因此更改了我的依赖项。但是一旦我同步应用程序 build.gradle 它就会抛出错误。

A problem occurred evaluating project ':app'.
> Could not find method ksp() for arguments [androidx.room:room-compiler:2.3.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Run Code Online (Sandbox Code Playgroud)

如何将其指向 ksp() 方法?

以前我对 kapt() 遇到了同样的问题,但通过添加解决了它id kotlin-kapt,但我还没有找到 ksp() 所需的依赖项。

我的应用程序 build.gradle 看起来像这样。相应的部分位于代码片段的下部并标记为//rooom <---------

    plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-android-extensions'
    //Room
    id 'kotlin-kapt'

}



android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.testapplication"
        minSdkVersion 24
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes { …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-room

22
推荐指数
3
解决办法
2万
查看次数

对于 ReviewManager Api,可以使用什么来代替 TaskException?

尝试按照谷歌教程进行应用内评论,我目前陷入了以下代码段:

val request = manager.requestReviewFlow()
request.addOnCompleteListener { task ->
    if (task.isSuccessful) {
        // We got the ReviewInfo object
        val reviewInfo = task.result
    } else {
        // There was some problem, log or handle the error code.
        @ReviewErrorCode val reviewErrorCode = (task.getException() as TaskException).errorCode
    }
}
Run Code Online (Sandbox Code Playgroud)

当我将其复制到 IDE 中时,它似乎没有拾取TaskException. 我可以在这里使用什么作为替代方案?

我已经添加:

implementation 'com.google.android.play:core:1.10.0'
implementation 'com.google.android.play:core-ktx:1.8.1'
Run Code Online (Sandbox Code Playgroud)

android kotlin

14
推荐指数
1
解决办法
1699
查看次数

Bindable 必须位于 Observable 类的成员上

我是数据绑定的新手,这是我的代码,但在构建时出现此错误

class DatabindingViewModel :ViewModel() {

val currentFruitName:LiveData<String>
    get() = FakeRepository.currentName

fun changeNameOnClick()=FakeRepository.changeRandomFoodName()

//two way LiveData
@Bindable
val editTextContext= MutableLiveData<String>()

private val _displayEditTexfContent=MutableLiveData<String>()
val displayEditTexfContent:LiveData<String>
    get()=_displayEditTexfContent

fun onDisplayEtText(){
    _displayEditTexfContent.value=editTextContext.value
}
Run Code Online (Sandbox Code Playgroud)

这是我的 xml 布局代码:

    <?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <data>
        <variable
            name="binding"
            type="ir.persiandesigners.myapplication.databinding.viewmodel.DatabindingViewModel" />
    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:id="@+id/textView"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="50dp"
            android:layout_marginLeft="50dp"
            android:layout_marginTop="32dp"
            android:layout_marginEnd="50dp"
            android:layout_marginRight="50dp"
            android:text="@{binding.currentFruitName}"
            android:textAppearance="@style/TextAppearance.AppCompat.Display1"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <Button
            android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="32dp"
            android:onClick="@{()->binding.changeNameOnClick()}"
            android:text="Get Random  Name"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/textView" />

        <EditText
            android:id="@+id/editText" …
Run Code Online (Sandbox Code Playgroud)

android android-databinding android-viewmodel

13
推荐指数
2
解决办法
4788
查看次数

如何从Android中的任何异步操作获取数据

(免责声明:人们通过使用诸如Facebook,firebase等请求使用异步操作时询问数据是否为空/不正确会引起很多问题。我的意图是向所有开始的人都提供一个简单的答案在android中进行异步操作,因为我在搜索后无法真正找到一个示例)

我正在尝试从我的一项操作中获取数据,当我调试它时,值就在那里了,但是当我运行它们时它们总是为空,我该如何解决呢?

火力基地

firebaseFirestore.collection("some collection").get()
            .addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
                @Override
                public void onSuccess(QuerySnapshot documentSnapshots) {
                     //I want to get these values here? 
            })
Run Code Online (Sandbox Code Playgroud)

脸书

GraphRequest request = GraphRequest.newGraphPathRequest(
            accessToken,
            "some path",
            new GraphRequest.Callback() {
                @Override
                public void onCompleted(GraphResponse response) {
                     //I want to get these values here? 
                }
            });
    request.executeAsync();
Run Code Online (Sandbox Code Playgroud)

java android kotlin firebase

9
推荐指数
3
解决办法
323
查看次数

什么是 Android 11 的“/dev/null”等价物

Android 11 对文件存储和访问进行了多项更改。显然,其中之一是不能再将输出定位到“/dev/null”(我的场景实际上在这个老问题中得到了准确解释)。

尽管引用的问题解决了特定问题,但有一件事仍未得到解答:Android 11 相当于“/dev/null”是什么。也就是说,如果不需要特定操作的输出(在我们的例子中,它是一个创建大文件的操作)。

android dev-null android-11

8
推荐指数
1
解决办法
204
查看次数

E/libprocessgroup:set_timerslack_ns 写入失败:不允许操作?

当我运行我的 android 应用程序时,我在我的 Logcat 中遇到了这个问题。有谁知道这个问题以及如何解决它?

该应用程序没有崩溃,但是当我每次尝试在 Google 地图的自动完成搜索栏中键入内容时,它都会关闭该活动。并返回上一个,在谷歌地图上显示当前位置。

<uses-library android:name="org.apache.http.legacy" android:required="false"/>
Run Code Online (Sandbox Code Playgroud)

这不起作用,这个问题实际上已经被谷歌修复了。

安卓

    android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.example.project_seraphim_disease_tracker"
        minSdkVersion 29
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}
Run Code Online (Sandbox Code Playgroud)

依赖

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.navigation:navigation-fragment:2.2.2'
    implementation 'androidx.navigation:navigation-ui:2.2.2'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    //new implementation
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'com.squareup.okhttp3:okhttp:4.1.0'
    implementation 'com.google.android.gms:play-services-maps:17.0.0' …
Run Code Online (Sandbox Code Playgroud)

android google-maps google-api google-places-api

6
推荐指数
1
解决办法
2万
查看次数

为什么 Android Studio 4.1 无法启动?

我尝试重新安装并删除 AppData 中所有与 android studio 相关的文件夹。我收到以下错误 -

2020-11-08 22:53:27,162 [   1831]  ERROR - rationStore.ComponentStoreImpl - Conflicting component name 'UsagesStatistic': class com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent and class com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent (componentManager=Application (containerState=ACTIVE) )
java.lang.Throwable: Conflicting component name 'UsagesStatistic': class com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent and class com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent (componentManager=Application (containerState=ACTIVE) )
        at com.intellij.openapi.diagnostic.Logger.error(Logger.java:146)
        at com.intellij.configurationStore.ComponentStoreImpl.doAddComponent(ComponentStoreImpl.kt:352)
        at com.intellij.configurationStore.ComponentStoreImpl.initPersistenceStateComponent(ComponentStoreImpl.kt:137)
        at com.intellij.configurationStore.ComponentStoreImpl.initComponent(ComponentStoreImpl.kt:103)
        at com.intellij.configurationStore.ComponentStoreWithExtraComponents.initComponent(ComponentStoreWithExtraComponents.kt:50)
        at com.intellij.serviceContainer.ComponentManagerImpl.initializeComponent$intellij_platform_serviceContainer(ComponentManagerImpl.kt:358)
        at com.intellij.serviceContainer.ComponentManagerImpl.createLightService(ComponentManagerImpl.kt:598)
        at com.intellij.serviceContainer.ComponentManagerImpl.getOrCreateLightService(ComponentManagerImpl.kt:486)
        at com.intellij.serviceContainer.ComponentManagerImpl.getLightService$intellij_platform_serviceContainer(ComponentManagerImpl.kt:458)
        at com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:401)
        at com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:394)
        at com.intellij.openapi.components.ServiceManager.getService(ServiceManager.java:20)
        at com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent.getInstance(UsageStatisticsPersistenceComponent.java:54)
        at com.intellij.ide.gdpr.ConsentOptions.saveConfirmedConsents(ConsentOptions.java:238)
        at com.intellij.ide.gdpr.ConsentOptions.setSendingUsageStatsAllowed(ConsentOptions.java:138)
        at com.intellij.ide.gdpr.ConsentOptionsProviderImpl.setSendingUsageStatsAllowed(ConsentOptionsProviderImpl.java:14)
        at com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent.loadState(UsageStatisticsPersistenceComponent.java:74)
Run Code Online (Sandbox Code Playgroud)

为什么会发生这种情况?

android android-studio

6
推荐指数
1
解决办法
392
查看次数

始终在线的 VPN 以编程方式打开 android

始终在线的 VPN 交换机可以以编程方式打开吗?

我已经添加了设备管理员权限。在那之后,我设置了始终与设备管理员一起使用

mDPM = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    mDeviceAdminSample = new ComponentName(this, DeviceAdminReceiver.class);
    isAdminApp = mDPM.isAdminActive(mDeviceAdminSample);

    if (isAdminApp) {
        try {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                mDPM.setAlwaysOnVpnPackage(mDeviceAdminSample,"", true);
            }
        } catch (PackageManager.NameNotFoundException namenotfoundexception) {
            namenotfoundexception.printStackTrace();
        } catch (Exception ex) {
        }
    }
Run Code Online (Sandbox Code Playgroud)

但它并没有启用始终开启。

我已经添加了包名

mDPM.setAlwaysOnVpnPackage(mDeviceAdminSample,"my.app.package.name", true);

但仍然没有启用开关。

那么这段代码在做什么呢?如何以编程方式启用它?

我希望这就像下图

永远在线的 VPN

java vpn android strongswan

6
推荐指数
1
解决办法
170
查看次数