无法在 Android Studio 中解析 net.sqlcipher 导入中的符号 'database'

Cannot resolve symbol 'database' in net.sqlcipher import in Android Studio

不知道为什么我有这个无法解析 net.sqlcipher 中的符号 'database'。我只是从 GitHub 克隆了 SQLCipher Android Test 并想测试一下。

也附上截图以供参考。

谢谢...

import net.sqlcipher.database.SQLiteDatabase;
import net.sqlcipher.database.SQLiteOpenHelper;

不要

import android.database.Cursor;

 import net.sqlcipher.Cursor;

你应该使用

对于app/build.gradle部分

   compile (name: 'android-database-sqlcipher-3.5.9', ext: 'aar')

添加下面项目的build.gradle文件

  repositories {
     jcenter()
    }

然后File-> Sync Project with Gradle Files & Clean->Rebuild Project.

阅读SQLCipher for Android Application Integration

仅供参考

We initially tested adding Java 8 support via the Jack toolchain. Over time, we realized the cost of switching to Jack was too high for our community when we considered the annotation processors, bytecode analyzers and rewriters impacted. Thank you for trying the Jack toolchain and giving us great feedback. You can continue using Jack to build your Java 8 code until we release the new support. Migrating from Jack should require little or no work.

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

在将 compileOptions 添加为 JavaVersion 8 并启用 JACK 后,我现在可以编译了

compileOptions {
  sourceCompatibility JavaVersion.VERSION_1_8
  targetCompatibility JavaVersion.VERSION_1_8
}

Jack 选项添加到里面 defaultConfig

jackOptions {
  enabled true
}

现在我的app/build.gradle变成了这个样子

apply plugin: 'com.android.application'

android {
  compileSdkVersion 26
  buildToolsVersion "26.0.1"
  defaultConfig {
    applicationId "net.zetetic.sqlcipher.test"
    minSdkVersion 14
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    jackOptions {
     enabled true
    }
 }
buildTypes {
 release {
  minifyEnabled false
  proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
 }
}

compileOptions {
 sourceCompatibility JavaVersion.VERSION_1_8
 targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

// For testing zip-based distributions:
//compile files('libs/sqlcipher.jar')


 // For testing AAR packages:
 compile 'net.zetetic:android-database-sqlcipher:3.5.9@aar'
}

非常感谢你们的帮助。