小编stu*_*ent的帖子

安装无法完成会话...签名不一致 - Android

我正在尝试运行我的项目,但我收到此错误:

安装失败,显示消息无法完成会话:INSTALL_FAILED_INVALID_APK:/data/app/vmdl1841863905.tmp/11_app-debug签名不一致.通过卸载现有版本的apk(如果存在)然后重新安装,可能会解决此问题.

警告:卸载将删除应用程序数据!

要卸载现有应用程序吗?

如果我按下是,几秒后它就会显示相同的错误.我试图手动删除该应用程序,但该应用程序已从我的手机中删除.

android

70
推荐指数
7
解决办法
7万
查看次数

将Android Studio升级到2.3后,调试控制台不显示消息

我刚刚将Android Studio的版本升级到2.3并且gradle到3.3版本,我丢失了一个最有用的功能,即Debug Console中的日志.当我使用调试模式运行应用程序时,调试控制台中显示的唯一日志是:

03/03 10:35:40: Launching app Split APKs installed 
$ adb shell am startservice com.myapp.android/com.android.tools.fd.runtime.InstantRunService 
$ adb shell am start -n "com.myapp.android/com.myapp.android.UI.SplashActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Connecting to com.myapp.android Connected to the target VM, address: 'localhost:8601', transport: 'socket'
Run Code Online (Sandbox Code Playgroud)

之后没有显示任何内容.知道如何解决这个问题吗?

android android-studio

18
推荐指数
2
解决办法
8590
查看次数

Gson:期待一个字符串,但是BEGIN_OBJECT

我试图阅读一个简单的JSON响应.

{"response":"ok"}

这是我的代码:

JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8"));
        String response = null;
        boolean success = false;

        reader.beginObject();
        if (reader.hasNext())
        {
            String token = reader.nextName();

            if (token.equals("response")) {
                response = reader.nextString();
            }
            else {
                reader.skipValue();
            }
        }
        reader.endObject();
        reader.close();
Run Code Online (Sandbox Code Playgroud)

但是我收到了这个错误:

期望一个字符串,但是BEGIN_OBJECT

我不明白我做错了什么.你能帮助我吗?

java gson

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

无法检测我们是否在 Google Compute Engine 上运行

我正在尝试使用 Google Cloud Speech 识别,但出现此错误

I/omputeEngineCredentials:无法检测我们是否在 Google Compute Engine 上运行。W/System.err: java.io.IOException: 应用程序默认凭据不可用。如果在 Google Compute Engine 中运行,它们就可用。否则,必须定义环境变量 GOOGLE_APPLICATION_CREDENTIALS 指向定义凭据的文件。有关 更多信息,请参阅 https://developers.google.com/accounts/docs/application-default-credentials

我从系统属性/环境变量/用户变量设置环境变量,并且我使用本指南手动设置凭据。

我已经搜索了与此相关的每个主题,但我无法让它发挥作用。我错过了什么?

android google-cloud-platform google-cloud-speech

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

找不到参数[{module = support-v4}]的方法exclude()

我试图在关闭即时运行的情况下运行我的应用程序,但是我收到此错误:

错误:任务':app:transformClassesWithJarMergingForDebug'的执行失败.

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目:android/support/v4/view/KeyEventCompatEclair.class

这是我的gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.jua.app"
        minSdkVersion 16
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile project(path: ':app_Data')
    compile files('libs/android-support-v4.jar')
}
Run Code Online (Sandbox Code Playgroud)

我尝试了这个线程的解决方案:

compile files('libs/android-support-v4.jar'){
    exclude module: "support-v4"
}
Run Code Online (Sandbox Code Playgroud)

现在,当我尝试同步gradle.build时,我收到此错误:

错误:(29,0)无法在org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection类型的文件集合中找到参数[{module = support-v4}]的方法exclude().打开文件

我现在有点失落,如果有人知道如何解决这个问题我会很感激.

编辑

我删除了

编译文件('libs/android-support-v4.jar')

完全,我仍然得到第一个错误.

java android gradle build.gradle

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

该请求的时间戳位于recvWindow之外

我正在尝试使用以下代码发出请求:

public JsonObject account() throws BinanceApiException { 
        return (new Request(baseUrl + "v3/account"))
                .sign(apiKey, secretKey, null).read().asJsonObject();
    }
Run Code Online (Sandbox Code Playgroud)

但我收到此错误:

BinanceApiException:错误:-1021,此请求的时间戳位于 recvWindow 之外。

我知道这和我的电脑和服务器的时间同步有关系。每次运行此代码时我都不会收到此错误。过去,我通过转到 Windows 设置、日期和时间、Internet 时间设置并将我的时间同步到 time.windows.com 来解决此错误。

java request binance

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

如何获取设备的默认 SpeechService 提供程序 - Android API 13

根据此页面,Android 13 删除了 SpeechService 实现,包括 RecognitionService 。它还提到:

应用程序应该使用设备的默认 SpeechService 提供程序,而不是硬编码特定的应用程序。

这是我在小于 13 的 API 上使用的代码:

String GOOGLE_RECOGNITION_SERVICE_NAME =
        "com.google.android.googlequicksearchbox/com.google.android.voicesearch.serviceapi.GoogleRecognitionService";

SpeechRecognizer speechRecognizer = SpeechRecognizer.createSpeechRecognizer(context,
            ComponentName.unflattenFromString(GOOGLE_RECOGNITION_SERVICE_NAME));
Run Code Online (Sandbox Code Playgroud)

关于如何获取设备的 SpeechService 的默认提供程序有什么想法吗?

android speech-recognition

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

迁移到 Androidx 后在模块 guava 错误中发现重复的类 com.google.common

这是我的 build.gradle 文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.app"
        multiDexEnabled true
        minSdkVersion 26
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/INDEX.LIST'
    }
}

configurations {
    all*.exclude group: 'com.google.guava', module: 'listenablefuture'
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.facebook.shimmer:shimmer:0.2.0'
    implementation 'androidx.multidex:multidex:2.0.0'
    testImplementation 'junit:junit:4.12'
    implementation 'com.victor:lib:1.0.4'
    implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
    implementation 'net.gotev:speech:1.3.1'
    implementation files('libs/YouTubeAndroidPlayerApi.jar')
    implementation …
Run Code Online (Sandbox Code Playgroud)

android android-gradle-plugin

3
推荐指数
1
解决办法
3115
查看次数

RecyclerView适配器仅显示第一项

我知道这个问题已经被问过很多次了,但是答案对我不起作用。我正在尝试使用水平放置。这是我的代码:

public class CalendarDaysAdapter extends RecyclerView.Adapter<CalendarDaysAdapter.MyViewHolder> {

    private ArrayList<String> list;

    public CalendarDaysAdapter(ArrayList<String> list)
    {
        this.list = list;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.fragment_calendar_days_item, parent, false);

        return new MyViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {

        String day = list.get(position);
        holder.daystxt.setText(day);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }


    public class MyViewHolder extends RecyclerView.ViewHolder {
        public TextView daystxt;

        public MyViewHolder(View view) {
            super(view);
            daystxt = (TextView) view.findViewById(R.id.daystxt);
        }
    }

} …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

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

SimpleDraweeView上的setImageURI:加载图像时的回调 - Android

我使用此代码显示图像:

SimpleDraweeView imageview = (SimpleDraweeView) findViewById(R.id.imageview);
String fileInternalPath = "....";
Uri bmpImageUri = Uri.parse(fileInternalPath);
imageview.setImageURI(bmpImageUri);
Run Code Online (Sandbox Code Playgroud)

我需要知道图像何时加载,所以我可以隐藏进度条.

有任何想法吗?

android

0
推荐指数
1
解决办法
2387
查看次数

TextView不会在父RelativeLayout居中

我试图将一个 TextView 放在一个相对布局中,但由于某种原因,TextView 的位置并不完全在中心,它在中心并稍微向下。当我添加第二个没有 id 的 RelativeLayout 时会出现此问题。

以下是我尝试解决问题但没有成功的两种方法:

第一的:

<RelativeLayout
   android:id="@+id/minus_one"
   android:layout_width="45dp"
   android:layout_height="match_parent"
   android:background="@color/lightgrey">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@drawable/ractangle_visual_feedback_selector"
                android:gravity="center">


            <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="22dp"
                    android:textStyle="bold"
                    android:text="-"/>

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

第二:

<RelativeLayout
                    android:id="@+id/minus_one"
                    android:layout_width="45dp"
                    android:layout_height="match_parent"
                    android:background="@color/lightgrey">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:background="@drawable/ractangle_visual_feedback_selector">


                <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerVertical="true"
                        android:layout_centerHorizontal="true"
                        android:textSize="22dp"
                        android:textStyle="bold"
                        android:text="-"/>

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

android android-layout

0
推荐指数
1
解决办法
831
查看次数