我正在阅读关于Android的房间库.我看到他们改变包装android来androidx.我不明白.请有人解释一下.
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
Run Code Online (Sandbox Code Playgroud)
即使这也适用于android包装.
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version"
Run Code Online (Sandbox Code Playgroud)
androidx而不是android.android android-architecture-components android-jetpack androidx
我升级到Android工作室3.1,我得到以下错误:
Default interface methods are only supported starting with Android N (--min-api 24): void android.arch.lifecycle.DefaultLifecycleObserver.onCreate(android.arch.lifecycle.LifecycleOwner)
Message{kind=ERROR, text=Default interface methods are only supported starting with Android N (--min-api 24): void android.arch.lifecycle.DefaultLifecycleObserver.onCreate(android.arch.lifecycle.LifecycleOwner), sources=[Unknown source file], tool name=Optional.of(D8)}
Run Code Online (Sandbox Code Playgroud)
这是我的gradle配置:
compileSdkVersion 27
//buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
multiDexEnabled true
//...
}
Run Code Online (Sandbox Code Playgroud)
正如你所看到的那样,我的目标27已经领先于它抱怨的24个?我该怎么做才能解决这个问题?如果我改为1.8 java不会让我失去很多客户?为什么我在升级android studio之前没有收到此错误.
我不知道这是关于我最近投入的LifecycleObserver类,它是在kotlin中,现在我将其更改为java但在清理项目后仍然得到相同的错误:
public class LifeCycleAwareObserver implements LifecycleObserver {
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
public void onAppBackgrounded() {
AnalyticsUtils.trackStartSession(true);
}
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void onAppForegrounded() {
AnalyticsUtils.trackStartSession(false);
}
Run Code Online (Sandbox Code Playgroud)
}
如何追踪错误的来源,以便我可以修复它?
这是我的版本依赖项:
project.ext {
firebase_version …Run Code Online (Sandbox Code Playgroud) 我已经成功配置了android-P SDK环境.当我尝试使用android设计支持库时,我面临项目构建错误.项目配置是:
IDE:3.2 Canary 17目标API:28编译API:28
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.app.navigationpoc"
minSdkVersion 21
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(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0-alpha3'
implementation 'androidx.constraintlayout:constraintlayout:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
implementation 'com.android.support:design:28.0.0-alpha3'
implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
}
Run Code Online (Sandbox Code Playgroud)
并且构建失败的错误是:
清单合并失败:来自[androidx.core:core:1.0.0-alpha3] AndroidManifest.xml:22:18-86的属性应用程序@ appComponentFactory值=(androidx.core.app.CoreComponentFactory)也出现在[com.android] .support:support-compat:28.0.0-alpha3] AndroidManifest.xml:22:18-91 value =(android.support.v4.app.CoreComponentFactory).建议:在AndroidManifest.xml:6:5-40:19中添加'tools:replace ="android:appComponentFactory"'来覆盖.
android android-studio android-design-library android-9.0-pie
我正在尝试生成一个签名的apk但我总是得到相同的错误.
To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 910 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB.
To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties.
Run Code Online (Sandbox Code Playgroud)
我无法归档该文件,但我尝试修改gradle-wrapper.properties但我仍然得到同样的错误.
这是我的gradle-wrapper.properties文件
#Thu May 05 20:51:44 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
org.gradle.jvmargs=-Xmx2048m
Run Code Online (Sandbox Code Playgroud)
什么是Jetifier?例如,要使用androidx打包的依赖项创建一个新项目,这个新项目需要将以下行添加到gradle.properties文件中:
android.enableJetifier=true
Run Code Online (Sandbox Code Playgroud)
那是什么意思 - "启用jetifier"?
使用Google所谓的Material Design 2.0需要您添加
implementation 'com.google.android.material:material:1.0.0-rc01'
Run Code Online (Sandbox Code Playgroud)
在应用程序Gradle中也包括
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
Run Code Online (Sandbox Code Playgroud)
这显示了冲突
这是日志所说的内容
Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0-rc02] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0-rc01] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory). Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:5:5-19:19 to override.
Run Code Online (Sandbox Code Playgroud)
即使在将其添加到Manifest之后,它也显示Manifest Merger因多次错误而失败
嗨,我是Android开发的新手,我正在尝试在YouTube上找到的有关MVVM的教程。视频中的示例项目使用AppCompat,但我将自己的代码转换为androidx,因为从我读取的内容中可以使用current(?)版本?我是否对这种想法感到误解?
无论如何,本教程的一部分利用了RecyclerView,我无法在我的activity_main.xml文件中访问它,表明v7是一个未解决的程序包。android.support.v7.widget.RecyclerView从v7开始以红色文本显示。我知道我可以将其还原为旧版本,但我想我正在努力使这项工作取得成功,因为它有望了解如何正确使用androidx?
我不知道如何在当前项目迁移到androidx的情况下将RecyclerView添加到项目中。
我尝试过的
implementation 'com.android.support:recyclerview-v7:28.0.0'根据文档添加我的依存关系:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
//RecyclerView
implementation 'com.android.support:recyclerview-v7:28.0.0'
// Lifecycle components
implementation "androidx.lifecycle:lifecycle-extensions:2.1.0-alpha04"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.1.0-alpha04"
// Room Components
implementation "androidx.room:room-runtime:2.1.0-alpha06"
annotationProcessor "androidx.room:room-compiler:2.1.0-alpha06"
}
Run Code Online (Sandbox Code Playgroud)
我的activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<view class="android.support.v7.widget.RecyclerView"
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listitem="@layout/todo_item"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud) 嗨,我当时在一个项目中,我使用了许多库依赖项。它工作正常,但突然开始报告错误。我是使用库依赖项的新手,并且正在使用Firebase数据库和存储,并且还在app文件夹下添加了google-services.json。我不明白问题出在哪里。预先感谢您的帮助
以下是错误列表
`执行任务:[:app:assembleDebug]
配置项目:app在[src / nullnull / debug,src / debug / nullnull,src / nullnull,src / debug,src / nullnDebug]中查找时找不到google-services.json
任务:app:buildInfoDebugLoader任务:app:preBuild UP-TO-DATE任务:app:preDebugBuild UP-TO-DATE任务:app:compileDebugAidl NO-SOURCE任务:app:compileDebugRenderscript UP-TO-DATE任务:app:checkDebugManifest UP- TO-DATE任务:app:generateDebugBuildConfig UP-TO-DATE任务:app:prepareLintJar UP-TO-DATE任务:app:generateDebugSources任务:app:javaPreCompileDebug UP-TO-DATE任务:app:mainApkListPersistenceDebug UP-TO-DATE任务: app:generateDebugResValues截止日期任务:app:generateDebugResources截止日期
任务:app:processDebugGoogleServices解析json文件:C:\ Users \ alexa \ AndroidStudioProjects \ eCommerceProject \ app \ google-services.json
任务:app:mergeDebugResources截止日期任务:app:createDebugCompatibleScreenManifests截止日期
任务:app:processDebugManifest失败C:\ Users \ alexa \ AndroidStudioProjects \ eCommerceProject \ app \ src \ main \ AndroidManifest.xml:22:18-91错误:属性application @ appComponentFactory value =(android.support.v4.app.Core.Factory )中的)也出现在[androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86中。值=(androidx.core.app.CoreComponentFactory)。建议:在AndroidManifest.xml:8:5-36:19的元素上添加'tools:replace =“ android:appComponentFactory”'以进行覆盖。
有关清单合并的更多信息,请参见http://g.co/androidstudio/manifest-merger。
任务:app:buildInfoGeneratorDebug
失败:构建失败,发生异常。
出了什么问题:任务':app:processDebugManifest'的执行失败。
清单合并失败:来自[com.android.support:support-compat:28.0.0]的属性application @ appComponentFactory value =(android.support.v4.app.CoreComponentFactory)来自AndroidManifest.xml:22:18-91 [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 …
android android-manifest android-support-library google-play-services
我正在关注这篇文章,以解决我的RN 0.59应用程序中的错误。我所做的是将2行添加到
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"
Run Code Online (Sandbox Code Playgroud)
AndroidManifest.xml在android/src/main。这是更改后的xml文件:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.emps_app">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme"
tools:replace="android:appComponentFactory" //<<===added 2 lines
android:appComponentFactory="whateverString">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
但是react-native run-android仍然抛出错误:
* What went wrong:
Execution failed for task ':app:generateDebugBuildConfig'.
> org.xml.sax.SAXParseException; systemId: file:/C:/D/code/js/emps_app/android/app/src/main/AndroidManifest.xml; lineNumber: 14; columnNumber: 52; The prefix "tools" for attribute "tools:replace" associated with an element type "application" …Run Code Online (Sandbox Code Playgroud) 我正在关注本教程:https : //www.youtube.com/watch?v=xtElLuzjA0U
我正在使用Android Studio 3.2.1-每当我实现“实现'me.zhanghai.android.materialprogressbar:library:1.6.1'”时,都会出现此错误:
Manifest merger failed : Attribute application@appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application>
element at AndroidManifest.xml:5:5-22:19 to override.
Run Code Online (Sandbox Code Playgroud)
当我第一次学习本教程时,所有内容都经过编译,我能够获得进度条,但是当我尝试调试和构建时,它崩溃了。现在,第二遍,实现依赖关系给了我同样的错误。
PS-我将其设置为4.4-当前的android
我看过“ https://developer.android.com/topic/libraries/support-library/packages ”,当我交叉引用时,似乎已经包含28.0.0了-我不确定该怎么做从这里做。
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
/*third party library*/
implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1'
}
Run Code Online (Sandbox Code Playgroud)
需要什么支持?我尝试实现tools:replace ...但是它给了我很多错误。
android ×10
androidx ×3
kotlin ×2
android-architecture-components ×1
gradle ×1
java-8 ×1
manifest ×1
react-native ×1