小编Sau*_*abh的帖子

无法完成会话:INSTALL_FAILED_INVALID_APK:已多次定义拆分lib_slice_0_apk

我正在尝试使用Constraint Layout.在Gradle构建成功完成.但我得到了"安装APK时出错",代码如下:

无法完成会话:INSTALL_FAILED_INVALID_APK:已多次定义拆分lib_slice_0_apk

这是我的布局代码:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.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"
    android:orientation="vertical"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".MainActivity"
    tools:showIn="@layout/app_bar_main">

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:hint="B?n c?m th?y th? nào" />

        <Button
            android:id="@+id/checkSicknessBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:text="Ki?m tra"
            android:textColor="@android:color/holo_blue_light"
            android:textStyle="bold" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:background="#9ed7ec"
        android:orientation="horizontal"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/linearLayout">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_margin="@dimen/content_margin"
            android:src="@drawable/baseline_access_alarm_white_48" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="center_vertical"
            android:text="Gi? u?ng thu?c s?p t?i 15:30"
            android:textAlignment="center"
            android:textColor="#f29d15"
            android:textSize="20dp" …
Run Code Online (Sandbox Code Playgroud)

android android-layout android-studio android-constraintlayout

9
推荐指数
1
解决办法
7154
查看次数

如何在 Google Play 商店私下发布应用程序?

我想私下发布一个应用程序,这意味着当用户在 Google Play 商店中搜索时应用程序不应显示。

我想与用户共享应用程序链接,然后用户将在 Google Play 商店下载该应用程序。

android google-play

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

当sdcard穿上时我怎么能自动安装apk?

我什么都不知道.如何在sdcard上安装时自动安装apk?

但是,我有一个问题,当我注册听取ACTION_MEDIA_SHAREDAndroidManifest.xml Em中的接收器时...我创建了一个扩展的接收器BroadcastReceive,我覆盖OnReceive().但是,最后,接收者无法获得任何行动.这是我的代码.令人沮丧的!!!!!

<receiver android:name=".SdcardPutOnListener"
    android:exported="true">

    <intent-filter>
        <action android:name="android.intent.action.ACTION_MEDIA_BAD_REMOVAL" />
        <action android:name="android.intent.action.ACTION_MEDIA_MEDIA_CHECKING" />
        <action android:name="android.intent.action.ACTION_MEDIA_EJECT" />
        <action android:name="android.intent.action.ACTION_MEDIA_MOUNTED" />
        <action android:name="android.intent.action.ACTION_MEDIA_NOFS" />
        <action android:name="android.intent.action.ACTION_MEDIA_REMOVED" />
        <action android:name="android.intent.action.ACTION_MEDIA_SHARED" />
        <action android:name="android.intent.action.ACTION_MEDIA_UNMOUNTABLE" />
        <data android:scheme="file" /> 
        <category android:name="android.intent.category.HOME"/>
    </intent-filter>
</receiver>

public class SdcardPutOnListener extends BroadcastReceiver {
    final static String TAG = "SdcardPutOnListener";
    public void onReceive(Context context, Intent intent) {
        Log.i(TAG, "receive broadcast " + intent.getAction()); 
    }
}
Run Code Online (Sandbox Code Playgroud)

android android-intent android-sdcard

5
推荐指数
1
解决办法
795
查看次数

如何在单个活动中加载多个 AndroidViewModel 以访问使用 Room 从多个表返回值的 LiveData

我正在 android 中开发一个电子商务应用程序,我必须在其中创建多个表,在其上插入数据并从该表中获取活动/片段中的数据(Spinner 中的加载值,基于运行条件的子查询等)。为此,我声明了 2 个表。地址,银行如下

银行.java

@Entity
public class Bank {

    @PrimaryKey(autoGenerate = true)
    public int id;
    public String bankId;
    public String bankName;
    public String bankType;

    public Bank() {
    }

    public String getBankId() {
        return bankId;
    }

    public String getBankName() {
        return bankName;
    }

    public String getBankType() {
        return bankType;
    }
}
Run Code Online (Sandbox Code Playgroud)

地址.java

@Entity
public class Address {

    @PrimaryKey(autoGenerate = true)
    public int id;
    public String state;
    public String district;
    public String block;
    public String id_panchayat;
    public String panchayat; …
Run Code Online (Sandbox Code Playgroud)

sqlite android android-room android-livedata android-viewmodel

5
推荐指数
1
解决办法
855
查看次数

通过通知将变量传递给活动

这是我的代码:

GCMIntentService:

Intent notificationIntent = new Intent(this, MainActivity.class);
notificationIntent.setAction(Intent.ACTION_MAIN);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
notificationIntent.putExtra("screen", activityToShow);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

PendingIntent intent2 = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

NotificationCompat.Builder nBuilder = 
        new NotificationCompat.Builder(this)
        .setSmallIcon(smallIconToDisplayInGCM)
        .setLargeIcon(largeIconToDisplayInGCM)
        .setContentTitle(title)
        .setContentText(text)
        .setSound(sound)
        .setTicker(ticker)
        .setContentIntent(intent2)
        .setAutoCancel(true);
Run Code Online (Sandbox Code Playgroud)

主要活动:

的onCreate()

onNewIntent(getIntent()) 
Run Code Online (Sandbox Code Playgroud)

onCreate()之外的新方法

@Override
public void onNewIntent(Intent intent){
    Bundle extras = intent.getExtras();
    String tabNumber = "";

    if(extras != null) {
        tabNumber = extras.getString("screen");
        Log.d("TEMP", "Tab Number: " + tabNumber);
        if(tabNumber.equals("") || (tabNumber == null)) {
            // Set the active tab to be the Home …
Run Code Online (Sandbox Code Playgroud)

notifications android

4
推荐指数
1
解决办法
6925
查看次数

当蓝牙断开连接或重新连接时,我的webview会重新加载

我有一个与蓝牙设备有问题的应用程序.当我断开连接或重新连接蓝牙设备时,应用程序似乎重新加载,或者我会说重新加载webview.它不会使应用程序崩溃,因为我正在使用接收器捕获连接和断开连接.这是我正在使用的代码和我坚持的地方.吐司正在工作,我无法弄清楚为什么它刷新整个视图.

public class MyBTReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if(intent.getAction().equals("android.bluetooth.device.action.ACL_CONNECTED"))
        {
            Toast.makeText(context, "BT connect", Toast.LENGTH_SHORT).show();
        }else if(intent.getAction().equals("android.bluetooth.device.action.ACL_DISCONNECTED"))
        {
        Toast.makeText(context, "BT disconnect", Toast.LENGTH_SHORT).show();
        }
    }
}

<receiver android:name=".MyBTReceiver">
    <intent-filter>
        <action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
        <action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />
     </intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)

android bluetooth broadcastreceiver android-webview

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

谷歌地图返回nullpointerexception谷歌地图Android V2

我有一个google mapfragment我的应用程序.有趣的是地图加载,但logcat显示一个NullPointerException,我只是在尝试更新地图上的相机时才注意到它,以便它可以自动放大marker.只有这样地图才会崩溃.否则,地图加载正常fragment但没有marker(即使我使用我的当前添加一个gps location).

EDITED*


我知道它崩溃是因为它googleMap是null,但我不明白为什么它返回null.地图渲染,我以前做过这个,它通常在那时崩溃.不呈现.


这是logcat错误

05-08 01:30:33.143  30130-30130/com.example.javed_000.famjam E/mapApp? java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.maps.GoogleMap com.google.android.gms.maps.SupportMapFragment.getMap()' on a null object reference
05-08 01:30:33.152  30130-30130/com.example.javed_000.famjam E/MapFragment? lat = 10.7270913 and Long = -61.5544451
05-08 01:30:33.155  30130-30130/com.example.javed_000.famjam D/AndroidRuntime? Shutting down VM
05-08 01:30:33.156  30130-30130/com.example.javed_000.famjam E/AndroidRuntime? FATAL EXCEPTION: main
Process: com.example.javed_000.famjam, PID: 30130
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.GoogleMap.animateCamera(com.google.android.gms.maps.CameraUpdate)' on a null object …
Run Code Online (Sandbox Code Playgroud)

android google-maps nullpointerexception android-fragments google-maps-android-api-2

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

如何使用新版本的 getresources().getColor?

我正在尝试使用颜色元素,getresources.getColor(resource id)但 android 告诉我它已被弃用 use getresources.getColor(resource id, theme)

我如何告诉它使用什么主题?我试过了,R.style.AppTheme但我收到一个错误,因为这是一个 int 值

public class TodoListItemView extends AppCompatTextView {
    public TodoListItemView(Context context, AttributeSet attributeSet, int ds) {
        super(context, attributeSet, ds);
        init();
    }

    public TodoListItemView(Context context) {
        super(context);
        init();
    }

    public TodoListItemView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        init();
    }

    private Paint marginPaint;
    private Paint linePaint;
    private int paperColor;
    private float margin;

    private void init() {
        Resources myResources = getResources();
        marginPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        marginPaint.setColor(getResources().getColor(R.color.notepad_margin));
        linePaint = new …
Run Code Online (Sandbox Code Playgroud)

android android-theme android-color

-1
推荐指数
1
解决办法
4963
查看次数