小编Jim*_*nts的帖子

Proguard 在 proguard-rules.pro 添加包名称后运行 R8 时检测到缺少类

AGPBI将此作为输出:

> Task :app:minifyReleaseWithR8
AGPBI: {"kind":"warning","text":"Unexpected reference to missing service class: META-INF/services/reactor.blockhound.integration.BlockHoundIntegration.","sources":[{"file":"/app/build/intermediates/merged_java_res/release/base.jar"}],"tool":"R8"}

AGPBI: {"kind":"warning","text":"Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in /app/build/outputs/mapping/release/missing_rules.txt.\n","sources":[{}]}

AGPBI: {"kind":"warning","text":"Missing class com.aayushatharva.brotli4j.Brotli4jLoader (referenced from: void io.netty.handler.codec.compression.Brotli.<clinit>() and 2 other contexts)\n

Missing class com.aayushatharva.brotli4j.decoder.DecoderJNI$Status (referenced from: void io.netty.handler.codec.compression.BrotliDecoder$1.<clinit>() and 1 other context)\n
Missing class com.aayushatharva.brotli4j.decoder.DecoderJNI$Wrapper (referenced from: com.aayushatharva.brotli4j.decoder.DecoderJNI$Wrapper io.netty.handler.codec.compression.BrotliDecoder.decoder and 4 other contexts)\n
Missing class com.aayushatharva.brotli4j.encoder.Encoder$Mode (referenced from: void io.netty.handler.codec.compression.BrotliOptions.<clinit>())\n
Missing class com.aayushatharva.brotli4j.encoder.Encoder$Parameters (referenced …
Run Code Online (Sandbox Code Playgroud)

android proguard kotlin

61
推荐指数
3
解决办法
6万
查看次数

switch case:error:case标签不会减少为整数常量

int value;

const int signalmin = some_function();

switch(value)
{
   case signalmin:
   break;
}
Run Code Online (Sandbox Code Playgroud)

我读取some_function的值并使用该int值来执行切换操作.C99编译器回馈:

错误:case标签不会减少为整数常量

但是我不能使用#define,因为在交换机执行之前正在读取int值.

c

33
推荐指数
3
解决办法
6万
查看次数

如何使用浓缩咖啡按下AlertDialog按钮

我想使用Espresso按下面按钮,但我不确定如何.我应该获得资源ID吗?或者如何设置AlertDialog的ID?

在此输入图像描述

@RunWith(AndroidJUnit4.class)
public class ApplicationTest {

@Rule
public ActivityTestRule<LoadingActivity> mActivityRule =
        new ActivityTestRule<>(LoadingActivity.class);

@Test
public void loginClickMarker() {
//Doesn't work:
    onView(withText("GA NAAR INSTELLINGEN")).perform(click());
}
}

public class PopupDialog {

public static void showGPSIsDisabled(Context context, String msg, final PopupDialogCallback popupDialogCallback) {
    new AlertDialog.Builder(context)
            .setTitle(context.getString(R.string.location_turned_off))
            .setMessage(msg)
            .setPositiveButton(context.getString(R.string.go_to_settings), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    popupDialogCallback.hasClicked();
                }
            }).show();
}
}
Run Code Online (Sandbox Code Playgroud)

android.support.test.espresso.NoMatchingViewException:找不到层次结构中的视图匹配:with text:is"GA NAAR INSTELLINGEN"

android android-studio android-espresso android-uiautomator

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

使用Call无效的模拟Retrofit响应调用

我在嘲笑APIService的反应.不幸的是它不起作用,我必须发回一个电话,但我不明白如何.问题是如何发送回Call对象.

@RunWith(AndroidJUnit4::class)
class ApiServiceTest {

    @Test
    fun testSomething() {
        val apiService = ApiServiceMock()
        val call = apiService.getStep1User()
        val result = call.execute()
        Assert.assertEquals("SomeUserValue", result.body()!!.getResponse())
    }
}
Run Code Online (Sandbox Code Playgroud)

这是模拟服务:

class ApiServiceMock : ApiService {
    override fun getStep1User(): Call<UserResponse> {
        // How to return an object of type Call<UserResponse> ?
        val response = "{ \"Response\": \"SomeUserValue\" }"
        val gson = Gson().toJson(response)
        return Response.success(gson)
    }
}
Run Code Online (Sandbox Code Playgroud)

这是api接口:

interface ApiService {

    @GET("/booky/step1user")
    fun getStep1User(): Call<UserResponse>

    companion object {

        val interceptor = HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)
        val client = OkHttpClient.Builder() …
Run Code Online (Sandbox Code Playgroud)

android retrofit2 okhttp3

13
推荐指数
3
解决办法
7719
查看次数

无法在Android Studio 2.1.1的gradle.properties文件中设置JVM参数gradle

- 在Mac OS X上运行Android 2.1.1

-App不在Android手机上.

gradle.properties文件的内容

org.gradle.jvmargs=-Xmx2048M
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

悬停时,IDE表示它是未使用的属性.它也应该是深蓝色而不是灰色.

输出:

:MyProjectDirName:transformClassesWithInstantRunSlicerForDebug
:MyProjectDirName:transformClassesWithDexForDebug
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.
For more information see   
https://docs.gradle.org/current/userguide/build_environment.html
Run Code Online (Sandbox Code Playgroud)

编译器的输出清楚地表明它丢弃了gradle.properties文件的内容.

内容build.gradle

android {
    dexOptions {
        javaMaxHeapSize "2g"
    }
}
Run Code Online (Sandbox Code Playgroud)

玩过这些设置,也没有成功:

在此输入图像描述

java android-gradle-plugin android-studio-2.1

12
推荐指数
1
解决办法
9566
查看次数

禁用"答案"但不禁用"Crashlytics"

在我的Android应用程序中安装"Crashlytics"时,它会自动安装"Answers".我只想安装"Crashlytics"并希望禁用"Answers".有谁知道这是怎么做到的吗?

在此输入图像描述

的build.gradle

dependencies {
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
    transitive = true;
}
Run Code Online (Sandbox Code Playgroud)

谢谢!

crashlytics twitter-fabric crashlytics-android

11
推荐指数
1
解决办法
3592
查看次数

Firebase云消息传递不适用于Android上的Build变体

我在Firebase中有2个项目:nl.companynamenl.companyname.acc:

在此输入图像描述

这是我的build.gradle:

flavorDimensions "type"
productFlavors {
    acceptance {
        dimension="type"
        applicationIdSuffix ".acc"
        versionNameSuffix "-acc"
    }
    production {
        dimension="type"
        applicationIdSuffix ""
        versionNameSuffix ""
    }
}
Run Code Online (Sandbox Code Playgroud)

下载google-services.json位于目录: app/google-services.json

Android Studio已登录Google帐户并已同步:

在此输入图像描述

消息显示为已成功发送: 在此输入图像描述

问题描述:

  • nl.companyname上发送消息时,它可以正常工作.

  • 发送邮件并定位设备的令牌ID时,它可以正常工作.

  • 但是nl.companyname.acc不起作用.

试过的步骤:

  • 我删除了Firebase中的.acc应用程序并重新添加(并下载了新的json文件).

在此输入图像描述

任何帮助是极大的赞赏.

android firebase firebase-cloud-messaging

8
推荐指数
1
解决办法
763
查看次数

当使用Android WebView显示键盘时,BottomNavigationView会上升

这个答案对WebViews不起作用,这也不适用.所以这个问题专门用于使用WebView时.下面的代码加载带有文本输入字段的网页.单击文本输入字段时,键盘出现.

public class MainActivity extends AppCompatActivity {

    @SuppressLint("SetJavaScriptEnabled")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

        final WebView webView = (WebView) findViewById(R.id.textFavorites);
        BottomNavigationView bottomNavigationView = (BottomNavigationView)
                findViewById(R.id.bottom_navigation);

        webView.loadUrl("https://www.journaldev.com");

        bottomNavigationView.setOnNavigationItemSelectedListener(
                new BottomNavigationView.OnNavigationItemSelectedListener() {
                    @Override
                    public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                        switch (item.getItemId()) {
                            case R.id.action_favorites:
                                webView.loadUrl("https://www.journaldev.com");
                                break;
                        }
                        return false;
                    }
                });
    }
}
Run Code Online (Sandbox Code Playgroud)

activity_main.xml中:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <WebView
        android:id="@+id/textFavorites"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="?attr/actionBarSize"/>

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        app:itemBackground="@color/colorPrimary"
        app:itemIconTint="@color/white"
        app:itemTextColor="@color/white"
        app:menu="@menu/bottom_navigation_main" …
Run Code Online (Sandbox Code Playgroud)

android webview bottomnavigationview

8
推荐指数
1
解决办法
356
查看次数

如何将 Android Kotlin 文件添加到 Cordova 插件项目

是否可以将 Android Kotlin 文件添加到Cordova 插件项目或仅支持 Java?

<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
        version="0.0.1">

  <!-- android -->
  <platform name="android">

    <source-file src="src/android/nl/companyname/kotlin/ScanMode.kt" target-dir="src/nl/companyname/kotlin"/>

  </platform>

</plugin>
Run Code Online (Sandbox Code Playgroud)

Java 文件会出现,但 Kotlin 文件不会。我也没有看到任何具有它的插件

java kotlin cordova-plugins

8
推荐指数
1
解决办法
385
查看次数

BottomNavigationView后退按钮行为应该像Youtube App一样工作但崩溃

重现步骤:

  1. 启动一个新的Android项目,选择" BottomNavigationView": 在此输入图像描述
  2. 用以下方法替换MainActivity:

    class MainActivity : AppCompatActivity() {
    
    private var fragmentIds = ArrayList<Int>()
    
    val fragmentA: FragmentA = FragmentA()
    private val fragmentB = FragmentB()
    private val fragmentC = FragmentC()
    
    private fun getFragment(fragmentId: Int): Fragment {
        when (fragmentId) {
            R.id.navigation_home -> {
                return fragmentA
            }
            R.id.navigation_dashboard -> {
                return fragmentB
            }
            R.id.navigation_notifications -> {
                return fragmentC
            }
        }
        return fragmentA
    }
    
    private fun updateView(fragmentId: Int) {
        var exists = false
        fragmentIds
                .filter { it == fragmentId }
                .forEach { exists …
    Run Code Online (Sandbox Code Playgroud)

android bottomnavigationview

7
推荐指数
1
解决办法
2474
查看次数