- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
尝试发布适用于 Android 的 React Native 应用程序,这两天令人悲伤,但收到此错误:
> Task :react-native-device-info:compileReleaseJavaWithJavac FAILED
/Users/myuser/project/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java:368: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
^
symbol: variable P
location: class VERSION_CODES
/Users/myuser/project/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java:370: error: cannot find symbol
locationEnabled = mLocationManager.isLocationEnabled();
^
symbol: method isLocationEnabled()
location: variable mLocationManager of type LocationManager
Note: /Users/myuser/project/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
FAILURE: Build failed with an exception.
我的project/android/build.gradle
文件是:
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 23
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
playServicesVersion = "16.0.0"
}
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
mavenLocal()
google()
maven {
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "27.1.1"
}
}
}
afterEvaluate {
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
targetSdkVersion 27
}
}
}
}
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 27
supportLibVersion = "27.1.0"
}
此外,我的 Android Studio 下载了以下组件:
我尝试了几次清理gradle缓存,但没有成功。我是java新手,不知道如何处理这个问题。
有什么想法吗?
<小时/>将compileSdkVersion更改为28后,现在出现以下错误:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':app:releaseCompileClasspath'.
> Could not resolve android.arch.lifecycle:viewmodel:1.1.0.
Required by:
project :app
> Cannot find a version of 'android.arch.lifecycle:viewmodel' that satisfies the version constraints:
Dependency path 'MobileApp:app:unspecified' --> 'com.android.support:appcompat-v7:28.0.0' --> 'com.android.support:support-fragment:28.0.0' --> 'android.arch.lifecycle:viewmodel:1.1.1'
Constraint path 'MobileApp:app:unspecified' --> 'android.arch.lifecycle:viewmodel' strictly '1.1.0' because of the following reason: releaseRuntimeClasspath uses version 1.1.0
Constraint path 'MobileApp:app:unspecified' --> 'android.arch.lifecycle:viewmodel' strictly '1.1.0' because of the following reason: releaseRuntimeClasspath uses version 1.1.0
Constraint path 'MobileApp:app:unspecified' --> 'android.arch.lifecycle:viewmodel' strictly '1.1.0' because of the following reason: releaseRuntimeClasspath uses version 1.1.0
> Could not find com.android.support:collections:27.1.1.
Required by:
project :app > com.android.support:appcompat-v7:28.0.0
project :app > com.android.support:support-compat:28.0.0
> Could not find com.android.support:cursoradapter:27.1.1.
Required by:
project :app > com.android.support:appcompat-v7:28.0.0
> Could not find com.android.support:loader:27.1.1.
Required by:
project :app > com.android.support:support-fragment:28.0.0
project :app > com.android.support:support-core-utils:28.0.0
> Could not resolve android.arch.lifecycle:viewmodel:1.1.1.
Required by:
project :app > com.android.support:support-fragment:28.0.0
> Cannot find a version of 'android.arch.lifecycle:viewmodel' that satisfies the version constraints:
Dependency path 'MobileApp:app:unspecified' --> 'com.android.support:appcompat-v7:28.0.0' --> 'com.android.support:support-fragment:28.0.0' --> 'android.arch.lifecycle:viewmodel:1.1.1'
Constraint path 'MobileApp:app:unspecified' --> 'android.arch.lifecycle:viewmodel' strictly '1.1.0' because of the following reason: releaseRuntimeClasspath uses version 1.1.0
Constraint path 'MobileApp:app:unspecified' --> 'android.arch.lifecycle:viewmodel' strictly '1.1.0' because of the following reason: releaseRuntimeClasspath uses version 1.1.0
Constraint path 'MobileApp:app:unspecified' --> 'android.arch.lifecycle:viewmodel' strictly '1.1.0' because of the following reason: releaseRuntimeClasspath uses version 1.1.0
> Could not find com.android.support:versionedparcelable:27.1.1.
Required by:
project :app > com.android.support:support-compat:28.0.0
> Could not find com.android.support:documentfile:27.1.1.
Required by:
project :app > com.android.support:support-core-utils:28.0.0
> Could not find com.android.support:localbroadcastmanager:27.1.1.
Required by:
project :app > com.android.support:support-core-utils:28.0.0
> Could not find com.android.support:print:27.1.1.
Required by:
project :app > com.android.support:support-core-utils:28.0.0
<小时/>
更新3
将 details.useVersion
更改为 28.0.0
后,我现在收到此错误:
> Task :app:bundleReleaseJsAndAssets FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Failed to capture fingerprint of input files for task ':app:bundleReleaseJsAndAssets' property '$1' during up-to-date check.
> Could not list contents of '/Users/myuser/myproject/node_modules/metro/node_modules/jest-haste-map/node_modules/.bin/sane'. Couldn't follow symbolic link.
最佳答案
您的 compileSdkVersion
是 27,但 Android P 的 API 是 28。如果您想使用 Android P 特定的 API,则需要将 compileSdkVersion
设置为 28,例如作为 Build.VERSION_CODES.P
常量,仅在 Android P 中引入。
根据 this blog post ,您应该始终寻求使用最新的 SDK 进行编译(无论您是否使用该 API 级别的任何功能)。
在 Migration to AndroidX 之前,如果您使用的支持库版本与您的 compileSdkVersion
不匹配,Lint 确实会提示。您可以忽略它,也可以升级到 28.0.0
,这是迁移到 AndroidX 之前的最后一个版本。
关于java - 由于 SDK_INT 和 VERSION_CODES.P 无法构建 Android APK - 那是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56925604/
从android.jar源代码来看,SDK_INT是一个常量: public static final int SDK_INT = 0; 所以,据我了解,在编译代码时,java编译将删除以下代码: i
我想使用此存储库来创建 react native 应用程序,而不是可以在前台和后台运行,但是当我下载此存储库并想要使用它时,我收到此错误: Task :app:compileDebugJavaWith
我尝试向已经运行的项目添加一些额外的代码,以显示一些 TextView 文本:一行告诉用户他们正在使用的 Android 版本。 但是,我添加了代码,项目本身并没有出现红色错误,但是应用程序运行时崩溃
这里是所有 Android 程序员的问题: 在我的应用中使用新旧 API 方法时,我发现了两种方法来处理不同的 API 方法。 测试 SDK_INT if (Build.VERSION.SDK_INT
THEME_HOLO_LIGHT在 API 23 中已弃用。 那么为什么在验证我在 API < 23 上使用它时仍然收到弃用警告? 我的 build.gradle 的相关部分: android {
我正在开发 Android 应用程序并希望支持 Android Q Beta。所以我在我的像素 1 上尝试了 android Q beta。 但是,当我想检查特定的 SDK 版本时,它显示的数字不正确
我为什么要像讨论的那样费心使用反射 here ,是否可以简单地从 Build.VERSION.SDK_INT 测试 Android 版本并有条件地运行低 API 版本不可用的功能? 那个article
如何在 mockk 中模拟 Build.VERSION.SDK_INT? 我做了以下事情: @Test fun testFoo(){ mockkStatic(Build::class)
在我的应用中,我正在检查 Build.VERSION.SDK_INT为了有条件地警告用户他们需要更新 Android 才能使用特定功能。它看起来像这样: if (Build.VERSION.SDK_I
Build.VERSION.SDK_INT 在 Android Q 模拟器上运行时返回 28 而不是 29。我有什么想念的吗?我正在尝试添加专门针对 Android Q 的逻辑,但我不知道如何正确确定
我想知道是否有办法 stub Build.Version.SDK_INT 的值?假设我在 ClassUnderTest 中有以下几行: if (Build.VERSION.SDK_INT >= Bui
代码如: if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) ed.apply()
我正在开发一个面向 API 11 (3.0) 但 minSDKVersion 为 7 (2.1) 的应用。 我以编程方式而不是使用 XML 生成我的 PreferenceActivity。在 Hone
所以,我有一段代码看起来像 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2){ // Do something }
我尝试在开发后构建我的 ionic 应用程序;但在这个过程中出现了以下错误: C:\incidentApp\platforms\android\app\src\main\java\com\moust\
尝试发布适用于 Android 的 React Native 应用程序,这两天令人悲伤,但收到此错误: > Task :react-native-device-info:compileReleaseJ
我正在实现 Firebase Cloud Messaging Quickstart 示例项目,网址为 https://github.com/firebase/quickstart-android/tr
我是一名优秀的程序员,十分优秀!