小编ghi*_*ita的帖子

未生成Dagger 2组件

在我的模块中,在我的基础Application类中

component = DaggerCompClassComponent.builder()
                .classModule(new ModuleClass()).build();
Run Code Online (Sandbox Code Playgroud)

它找不到DaggerCompClassComponent.

我有模块build.gradle

apply plugin: 'com.neenbedankt.android-apt'
.........................
apt 'com.google.dagger:dagger-compiler:2.8'
compile 'com.google.dagger:dagger:2.8'
provided 'javax.annotation:jsr250-api:1.0'
Run Code Online (Sandbox Code Playgroud)

在Project build.gradle中,

 classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
Run Code Online (Sandbox Code Playgroud)

我已经完成了build/rebuild/clean/restart项目.我有一个Component类,我在其中注入对象和一个ModuleClass,我提供了要注入的对象.

不生成Dagger组件的原因是什么.上课?

编辑:

这是我的ModuleClass,用@Module注释:

@Provides
@Singleton
public Interceptor provideInterceptor() {
    return new Interceptor() {
        @Override
        public Response intercept(Chain chain) throws IOException {
            Request.Builder builder = chain.request().newBuilder();

            builder.addHeader("AppName-Android", BuildConfig.VERSION_NAME + "-" + BuildConfig.VERSION_CODE)
                    .addHeader("Content-Type", "application/json");

            return chain.proceed(builder.build());
        }
    };
}

@Provides
@Singleton
OkHttpClient provideOkHttpClient(Interceptor interceptor) {
    OkHttpClient.Builder builder = new OkHttpClient.Builder();
    builder.interceptors().add(interceptor);
    return builder.build();
}

@Provides
@Singleton
Retrofit provideRetrofit(OkHttpClient …
Run Code Online (Sandbox Code Playgroud)

android dagger

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

无法解析com.android.support:support-annotations 26.0.1

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    testCompile 'junit:junit:4.12'

    // ButterKnife
    compile 'com.jakewharton:butterknife:8.8.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

    // Parse SDK
    compile 'com.parse:parse-android:1.16.0'
}
Run Code Online (Sandbox Code Playgroud)

这是我的应用程序gradle依赖项.我不知道如何解决它.我尝试从SDK Manager Android SDK Build Tools 26.0.1安装,我也有最新版本的Android支持.

android android-support-library

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

错误膨胀类 com.google.android.material.textfield.TextInputLayout

这是我的应用主题: <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">

由于未使用所需的主题,我遇到了膨胀错误。在Manifest我没有覆盖我收到此错误的活动的主题,因此使用了定义的 AppTheme styles.xml

错误:

 android.view.InflateException: Binary XML file line #122: Binary XML file line #122: Error inflating class com.google.android.material.textfield.TextInputLayout
    Caused by: android.view.InflateException: Binary XML file line #122: Error inflating class com.google.android.material.textfield.TextInputLayout
    Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
        at android.view.LayoutInflater.createView(LayoutInflater.java:647)
      ...
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
     Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant).
        at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:240)
        at com.google.android.material.internal.ThemeEnforcement.checkMaterialTheme(ThemeEnforcement.java:215)
        at com.google.android.material.internal.ThemeEnforcement.checkCompatibleTheme(ThemeEnforcement.java:143)
        at com.google.android.material.internal.ThemeEnforcement.obtainTintedStyledAttributes(ThemeEnforcement.java:116)
Run Code Online (Sandbox Code Playgroud)

这是我的 xml:

  <com.google.android.material.textfield.TextInputLayout …
Run Code Online (Sandbox Code Playgroud)

android android-layout kotlin material-components-android

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

Apk反编译错误:找不到d2j-dex2jar命令

我尝试从.apk获取源代码

我按照这里的步骤 有没有办法从APK文件中获取源代码?但是在步骤2.4,当我在我的cmd上写道时,我dex2jar path> d2j-dex2jar classes.dex得到了

" 'd2j-dex2jar'未被识别为内部或外部命令,可操作的程序或批处理文件. "

任何解决方案

apk dex2jar

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

如何将 libgdx 添​​加到现有项目

我提供了一个用 android 制作的应用程序,它有一个导航抽屉,里面有一个游戏列表。我必须创建另一个游戏并将其放在那里。我必须创建的游戏必须使用libGDX,但原始应用程序没有使用这个库。

是否有可能做到这一点 ?如果是,如何将 libgdx 添​​加到现有项目中。在 github 上,我只找到了如何使用 libGDx 启动新项目,而不是如何将其添加到现有代码中。谢谢。

android libgdx

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

组件导航,从带参数的 backstack 弹出

假设我有三个片段,A、B、C;

A -> B <-> C

B和C之间是循环关系。B 或 C 片段都需要arguments,例如

     val args = Bundle()

     args.putString("StringKeyBC", argValueBtoC)       
     findNavController().navigate(R.id.action_fragmentB_to_fragmentC, args, null)

     args.putString("StringKeyCB", argValueCtoB)       
     findNavController().navigate(R.id.action_fragmentC_to_fragmentB, args, null)
Run Code Online (Sandbox Code Playgroud)

问题是每次我在 B 和 C 之间移动时,片段都会添加到后堆栈中,我不希望那样。如果片段已经回到堆栈,我只想弹出它,但如果我使用,popBackStack我不能再添加参数:

public boolean popBackStack(@IdRes int destinationId, boolean inclusive)
Run Code Online (Sandbox Code Playgroud)

那么,如何在不每次都将它们添加到后堆栈的情况下在两个片段之间不断切换?

navigation android android-fragments kotlin android-architecture-navigation

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

Firebase 连接问题 - Android

我有一个已经有 iOS 应用程序的 Firebase 项目。我在项目中添加了一个 android 应用程序。它卡在这一步:

在此处输入图片说明

我有uninstalled/reinstalled/clean cache/rebuild/burn emulator, buy another one/I verified that the SHA-1 is correctly for the build variant that I have added to the console/etc.它仍然卡住了。我也从项目中删除了该应用程序并再次添加了几次。

使用另一个帐户,我创建了另一个 Firebase 项目,然后我创建了一个新的 android 应用程序,我已将其添加到新的 Firebase 项目中(与上述步骤相同)并且它工作正常(对于具有新项目的新应用程序)。

但是对于带有我现有 android 应用程序的现有 Firebase 项目,无论我做了什么,它都会说“检查应用程序是否已与我们的服务器通信。您可能需要卸载并重新安装您的应用程序。

最后我点击了跳过这一步

问题是它没有与 Firebase 链接的应用程序,当我查看控制台时,我仍然看到 0 个活动设备,但我应该看到我测试过的 2 个设备:

在此处输入图片说明

我从这里添加了确切的版本:

在此处输入图片说明

我应该寻找什么,该应用未与 Firebase 连接的可能原因是什么?

android kotlin firebase firebase-authentication firebase-cloud-messaging

5
推荐指数
0
解决办法
3171
查看次数

TextInputLayout 轮廓提示颜色

我在 TextInputLayout 上有一个奇怪的错误。com.google.android.material.textfield.TextInputEditText焦点的提示颜色变为白色。

在此处输入图片说明

这就是我设置它的方式:

<com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/inputEmail"
                        style="@style/EditText.OutlinedBox"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginTop="10dp"
                        android:layout_marginEnd="16dp"
                        app:boxStrokeColor="@color/colorBrand">

                        <com.google.android.material.textfield.TextInputEditText
                            android:id="@+id/editTextEmail"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="start"
                            android:hint="@string/edt_hint_email"
                            android:inputType="textEmailAddress"
                            android:textAlignment="viewStart" />
                    </com.google.android.material.textfield.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)

..这是风格:

 <style name="EditText.OutlinedBox" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
        <item name="android:minHeight">56dp</item>
        <item name="android:textSize">18sp</item>
        <item name="android:fontFamily">@font/dubai_regular</item>
        <item name="hintEnabled">true</item>
    </style>
Run Code Online (Sandbox Code Playgroud)

编辑:添加 style.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="TextAppearance.AppCompat.Title" parent="TextAppearance.AppCompat.Large">
        <item name="android:textColor">@color/colorTextPrimary</item>
        <item name="android:layout_gravity">center_vertical</item>
    </style>


    <style name="EditText.OutlinedBox" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
        <item name="android:minHeight">56dp</item>
        <item name="android:textSize">18sp</item>
        <item name="android:fontFamily">@font/dubai_regular</item>
        <item name="hintEnabled">true</item>
    </style>

    <style name="Button" parent="Widget.MaterialComponents.Button">
        <item name="cornerRadius">10dp</item>
        <item name="backgroundTint">@color/colorAccent</item>
        <item name="android:minHeight">56dp</item>
        <item name="android:textAllCaps">false</item>
        <item name="android:fontFamily">@font/dubai_bold</item>
        <item name="android:elevation">0dp</item>
        <item …
Run Code Online (Sandbox Code Playgroud)

layout android kotlin android-textinputlayout android-textinputedittext

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

条目名称“org/joda/time/tz/data/Europe/Dublin”相撞

编译签名的 Apk 时突然出现此错误,不知道如何解决。

Entry name 'org/joda/time/tz/data/Europe/Dublin' collided
Run Code Online (Sandbox Code Playgroud)

它没有指向任何行,这是 Joda 库导入:

implementation "joda-time:joda-time:2.9.9"
Run Code Online (Sandbox Code Playgroud)

android build jodatime gradle kotlin

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

Android Studio 3.5错误:无法解析':app @ debug / compileClasspath'的依赖项

尝试同步gradle时出现此错误。我正在使用Android Studio 3.5gradle 5.4.1。在此配置下运行正常,突然我开始出现此错误。

**ERROR**: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-location:[15.0.0, 16.0.0).
Affected Modules: app

**ERROR**: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-location:[15.0.0, 16.0.0).
Affected Modules: app

**ERROR**: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.firebase:firebase-messaging:[10.2.1, 12.1.0).
Affected Modules: app

**ERROR**: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-location:[10.2.1, 12.1.0).
Affected Modules: app
Run Code Online (Sandbox Code Playgroud)

这是我的app/build.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions' …
Run Code Online (Sandbox Code Playgroud)

android gradle kotlin android-studio

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