相关疑难解决方法(0)

API 28(P)的Android设计支持库无法正常工作

我已经成功配置了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

90
推荐指数
10
解决办法
15万
查看次数

Android Studio 3.6.1 | 错误:“此项目使用 AndroidX 依赖项”

我已将我的 Android Studio 和targetSdkVersion(build.gradle) 更新为 29。我迁移到了 AndroidX。现在 Gradle 构建给了我这两个错误。

此项目使用 AndroidX 依赖项,但未启用 'android.useAndroidX' 属性。在 gradle.properties 文件中将此属性设置为 true 并重试。

检测到以下 AndroidX 依赖项:androidx.versionedparcelable:versionedparcelable:1.0.0、androidx.fragment:fragment:1.0.0、androidx.slidingpanelayout:slidingpanelayout:1.0.0、androidx.core:core:1.0.0、androidx.customview :customview:1.0.0, androidx.swiperrefreshlayout:swiperrefreshlayout:1.0.0, androidx.interpolator:interpolator:1.0.0, androidx.loader:loader:1.0.0, androidx.drawerlayout:drawerlayout:1.0.0, androidx.viewpage :viewpager:1.0.0, androidx.collection:collection:1.0.0, androidx.localbroadcastmanager:localbroadcastmanager:1.0.0, androidx.lifecycle:lifecycle-common:2.0.0, androidx.arch.core:core-common:2.0 .0, androidx.annotation:annotation:1.1.0, androidx.lifecycle:lifecycle-livedata:2.0.0, androidx.legacy:legacy-support-core-ui:1.0.0, androidx.lifecycle:lifecycle-viewmodel:2.0 .0,androidx.lifecycle:lifecycle-livedata-core:2。0.0, androidx.arch.core:core-runtime:2.0.0, androidx.legacy:legacy-support-core-utils:1.0.0, androidx.documentfile:documentfile:1.0.0, androidx.cursoradapter:cursoradapter:1.0。 0, androidx.lifecycle:lifecycle-runtime:2.0.0, androidx.coordinatorlayout:coordinatorlayout:1.0.0, androidx.asynclayoutinflater:asynclayoutinflater:1.0.0, androidx.print:print:1.0.0

我的代码是:MainActivity.java

package it.manuel.myapp;

import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.DownloadManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Build;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; …
Run Code Online (Sandbox Code Playgroud)

dependencies android android-studio

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

合并dex程序类型时出错:android.support.v4.os.ResultReceiver $ MyResultReceiver

合并dex时出错

以下是依赖项.

ext {
    anko_version='0.10.5'
    support_lib='1.0.0-alpha1'
    room_lib = "1.1.0"
}
dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "androidx.cardview:cardview:$support_lib"
    implementation "com.google.android.material:material:$support_lib"
    implementation "androidx.appcompat:appcompat:$support_lib"
    implementation "org.jetbrains.anko:anko:$anko_version"
    implementation "androidx.lifecycle:lifecycle-extensions:2.0.0-alpha1"
    implementation "android.arch.persistence.room:runtime:$room_lib"
    annotationProcessor "android.arch.persistence.room:compiler:$room_lib"
}
Run Code Online (Sandbox Code Playgroud)

错误

  • 出了什么问题:任务执行失败':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

    com.android.builder.dexing.DexArchiveMergerException:合并dex存档时出错:/app/build/intermediates/transforms/dexBuilder/debug/0.jar,程序类型已存在:android.support.v4.os.ResultReceiver $ 1

android android-support-library android-gradle-plugin

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

如何使用FusedLocationProviderClient获取GoogleMap中的当前位置

我想定期(比如每2分钟)当前位置更新为这个我下面的官方文档,我写了这个代码,但它不会给当前的位置即使在我传递requestLocationUpdates LocationRequest对象指定每两分钟更新( ),这里是代码:

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback,
    GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener{

private FusedLocationProviderClient FusedLocationClient;
private GoogleApiClient mGoogleApiClient;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();
    }

 SupportMapFragment map = 
  getSupportFragmentManager().findFragmentById(R.id.map));

  map.getMapAsync(this);

  FusedLocationClient LocationServices.getFusedLocationProviderClient(this);
}


@Override
public void onConnected(Bundle bundle) {
    FusedLocationClient.getLastLocation()
            .addOnSuccessListener(this, new OnSuccessListener<Location>() {
                @Override
                public void onSuccess(Location location) {

                    if (location != null) {
                        Log.i("MainActivity ", "" + location.getLongitude()) 
                    }
                }
            });
FusedLocationClient = …
Run Code Online (Sandbox Code Playgroud)

java android google-maps-android-api-2 android-fusedlocation

25
推荐指数
2
解决办法
4万
查看次数

使用 groupid com.android.support 和 androidx.* 的依赖无法组合但找到了 IdeMavenCoordinates

我想升级 Google 图书馆:

build.gradle(应用程序):

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}"
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
    // Here an error appears.
    implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
    implementation "com.android.support:support-v4:${supportLibraryVersion}"
    implementation "com.android.support:design:${supportLibraryVersion}"
    implementation "com.android.support:support-vector-drawable:${supportLibraryVersion}"
    implementation "com.android.support:recyclerview-v7:${supportLibraryVersion}"
    implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation "com.android.support:support-compat:${supportLibraryVersion}"

    // These libraries are updated.

    // Google Maps.
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.google.android.gms:play-services-location:17.0.0'

    implementation "com.google.firebase:firebase-messaging:19.0.1"
    implementation "com.google.android.gms:play-services-base:17.0.0"

    // Firebase.
    implementation 'com.google.firebase:firebase-config:18.0.0'
    implementation 'com.google.firebase:firebase-core:17.0.0'

    // Multidex.
    implementation 'com.android.support:multidex:1.0.3'
}
Run Code Online (Sandbox Code Playgroud)

build.gradle(项目):

buildscript {
    ext.compile_sdk_version = 29
    ext.min_sdk_version = 16
    ext.target_sdk_version = 29
    ext.kotlin_version = '1.3.40'
    ext.supportLibraryVersion = …
Run Code Online (Sandbox Code Playgroud)

android androidx

12
推荐指数
0
解决办法
7747
查看次数

在 Android 中添加 Facebook 登录依赖项后出错

我想将我的应用程序与 facebook 登录集成,但是在添加以下依赖项并同步 Gradle 时:

implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

ERROR: Failed to resolve: legacy-support-v4
Affected Modules: app


ERROR: Failed to resolve: browser
Affected Modules: app


ERROR: Failed to resolve: legacy-support-core-utils
Affected Modules: app


ERROR: Failed to resolve: media
Affected Modules: app
Run Code Online (Sandbox Code Playgroud)

我在应用程序级别的build.gradle

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
}

repositories { }

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.***************"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }
    buildTypes …
Run Code Online (Sandbox Code Playgroud)

java android facebook facebook-android-sdk android-gradle-plugin

5
推荐指数
2
解决办法
1676
查看次数