java应用程序可以在模拟器上工作(通过usb连接设备),但当从googleplay商店下载数据时就不行了?

9fkzdhlc  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(276)

抱歉,我知道论坛上已经有类似的问题了,但是没有一个问题和我在这里遇到的问题完全一样。我刚刚完成了一个android教程课程,并开发和发布了我的第一个应用程序-我是一个新手,所以原谅我,如果我做了一些愚蠢的事情!
我的应用程序在笔记本电脑上运行良好——在各种模拟器上运行,有各种sdk版本,当用usb电缆插入笔记本电脑时,也能在真实设备上运行。然而,当我把它上传到googleplay商店时(要等3天才能得到评论!)当我把它下载到通过usb连接的同一个设备上时,它就不工作了。
应用程序在第一页打开之前就崩溃了,我能得到的唯一错误信息是googleplay提供的错误信息——包括在下面。问题似乎是我的解析初始化,但我不知道什么或为什么?任何帮助都将不胜感激!
googleplay错误日志:

java.lang.RuntimeException: 
  at android.app.ActivityThread.handleMakeApplication (ActivityThread.java:7041)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6989)
  at android.app.ActivityThread.access$1600 (ActivityThread.java:272)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2055)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loop (Looper.java:237)
  at android.app.ActivityThread.main (ActivityThread.java:8016)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1076)
Caused by: java.lang.IllegalArgumentException: 
  at com.parse.ParseObjectSubclassingController.registerSubclass (ParseObjectSubclassingController.java:75)
  at com.parse.ParseObject.registerSubclass (ParseObject.java:491)
  at com.parse.ParseObject.registerParseSubclasses (ParseObject.java:3486)
  at com.parse.Parse.initialize (Parse.java:395)
  at com.baileycoding.StarterApplication.onCreate (StarterApplication.java:29)
  at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1190)
  at android.app.ActivityThread.handleMakeApplication (ActivityThread.java:7036)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6989)
  at android.app.ActivityThread.access$1600 (ActivityThread.java:272)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2055)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loop (Looper.java:237)
  at android.app.ActivityThread.main (ActivityThread.java:8016)
  at java.lang.reflect.Method.invoke (Method.java)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1076)

应用程序清单.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.baileycoding"
    android:targetSandboxVersion="1" >

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

    <application
        android:name="com.baileycoding.StarterApplication"
        android:allowBackup="true"
        android:usesCleartextTraffic="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.AppCompat.Light">
        <activity android:name="com.baileycoding.AboutActivity"></activity>
        <activity android:name="com.baileycoding.WineResult" />
        <activity android:name="com.baileycoding.MyResultsActivity" />
        <activity android:name="com.baileycoding.ScoreboardActivity" />
        <activity android:name="com.baileycoding.RatingActivity" />
        <activity android:name="com.baileycoding.GuessDescriptionActivity" />
        <activity android:name="com.baileycoding.GuessTastesActivity" />
        <activity android:name="com.baileycoding.GuessGrapeActivity" />
        <activity android:name="com.baileycoding.GuessCRVActivity" />
        <activity android:name="com.baileycoding.WineListActivity" />
        <activity android:name="com.baileycoding.StartGameActivity" />
        <activity android:name="com.baileycoding.WineAssignmentActivity" />
        <activity android:name="com.baileycoding.PrepActivity" />
        <activity android:name="com.baileycoding.WineInfoActivity2" />
        <activity
            android:name="com.baileycoding.WineInfoActivity"
            android:windowSoftInputMode="adjustPan" />
        <activity android:name="com.baileycoding.EventIdConfirmationActivity" />
        <activity
            android:name="com.baileycoding.CreateNewEventActivity"
            android:windowSoftInputMode="adjustPan" />
        <activity android:name="com.baileycoding.EventMenuActivity" />
        <activity android:name="com.baileycoding.InitialMenuActivity" />
        <activity
            android:name="com.baileycoding.MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <meta-data
            android:name="preloaded_fonts"
            android:resource="@array/preloaded_fonts" />
    </application>

</manifest>

grad尔大厦(模块):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion '22.0.1'

    defaultConfig {
        applicationId "com.baileycoding.thegrapeunknown"
        minSdkVersion 26
        targetSdkVersion 29
        versionCode 2
        versionName '1.1'
        multiDexEnabled true
    }
    dexOptions {
        javaMaxHeapSize "4g"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    compile 'com.android.support:appcompat-v7:26.0.0'
    compile 'com.parse.bolts:bolts-tasks:1.3.0'
    compile 'com.parse:parse-android:1.13.0'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.android.support:multidex:1.0.0'
}

build.gradle(项目):

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        mavenCentral()
        jcenter()
        google()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.0'
    }
}

allprojects {
    repositories {
        mavenCentral()
        google()
    }
}

ext {
    compileSdkVersion = 22
    buildToolsVersion = "23.0.1"

    minSdkVersion = 9
    targetSdkVersion = 23
    defaultVersionCode = 1.1
}

分析启动程序活动:

package com.baileycoding;

import android.app.Application;

import com.parse.Parse;
import com.parse.ParseACL;

public class StarterApplication extends Application {

  @Override
  public void onCreate() {
    super.onCreate();

    // Enable Local Datastore.
    Parse.enableLocalDatastore(this);

    // Add your initialization code here
    Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
            .applicationId("myappID")
            .clientKey("xxxxxxxxxxx") //hidden for security - let me know if useful to see
            .server("http://18.220.164.203/parse/")
            .build()
    );

    //PARSE SETUP STATEMENTS
    //ParseUser.enableAutomaticUser();

    ParseACL defaultACL = new ParseACL();
    defaultACL.setPublicReadAccess(true);
    defaultACL.setPublicWriteAccess(true);
    ParseACL.setDefaultACL(defaultACL, true);

  }
}

主要活动。 java 语:

package com.baileycoding;

import android.content.Intent;
import android.os.Bundle;
import android.support.constraint.ConstraintLayout;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.parse.FindCallback;
import com.parse.LogInCallback;
import com.parse.ParseAnalytics;
import com.parse.ParseException;
import com.parse.ParseObject;
import com.parse.ParseQuery;
import com.parse.ParseUser;
import com.parse.SignUpCallback;
import com.baileycoding.R;

import java.util.List;

public class MainActivity extends AppCompatActivity implements View.OnKeyListener, View.OnClickListener {

    EditText emailEditText;
    EditText passwordEditText;
    EditText nameEditText;
    Button loginButton;
    TextView switchTextView;
    ConstraintLayout backgroundLayout;

    Boolean loginMode; // 1 = signup, 0 = login
    String email;
    String password;
    String name;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setTheme(R.style.MyTheme);
        setContentView(R.layout.activity_main);

        //setTitle("Welcome");
        if (getSupportActionBar() != null) {
            getSupportActionBar().hide();
        }

        emailEditText = (EditText) findViewById(R.id.emailEditText);
        passwordEditText = (EditText) findViewById(R.id.passwordEditText);
        nameEditText = (EditText) findViewById(R.id.nameEditText);
        loginButton = (Button) findViewById(R.id.loginButton);
        switchTextView = (TextView) findViewById(R.id.switchTextView);
        backgroundLayout = findViewById(R.id.backgroundLayout);

        passwordEditText.setOnKeyListener(this);
        nameEditText.setOnKeyListener(this);
        backgroundLayout.setOnClickListener(this);

        loginMode = false;
        nameEditText.setVisibility(View.GONE);

        ParseQuery<ParseObject> query = ParseQuery.getQuery("User");
        query.whereNotEqualTo("username","test");
        query.findInBackground(new FindCallback<ParseObject>() {
            @Override
            public void done(List<ParseObject> objects, ParseException e) {
                if(e!=null || objects.size()==0){
                    Toast.makeText(MainActivity.this, "You are not currently logged in", Toast.LENGTH_SHORT).show();
                    if(e!=null){ e.printStackTrace();}
                } else {
                    if (ParseUser.getCurrentUser() != null) {
                        String currentUser = ParseUser.getCurrentUser().toString();
                        //ParseUser.logOut();
                        Toast.makeText(MainActivity.this, "Currently logged in as " + ParseUser.getCurrentUser().getUsername(), Toast.LENGTH_SHORT).show();
                        moveToInitialMenu();
                    }
                }
            }
        });

        ParseAnalytics.trackAppOpenedInBackground(getIntent());
    }

    @Override
    public boolean onKey(View v, int keyCode, KeyEvent event) {

        if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN) {
            loginOrSignup(v);
        }
        return false;
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.backgroundLayout) {
            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
            inputMethodManager.hideSoftInputFromWindow(getWindow().getDecorView().getRootView().getWindowToken(), 0);
        }
    }

    public void switchToSignup(View view) {

        if (loginMode == false) {
            loginMode = true;
            Log.i("Login mode switched to", "true; signup mode");
            loginButton.setText("SIGNUP");
            switchTextView.setText("Already have an account? Log in here");
            nameEditText.setVisibility(View.VISIBLE);
        } else {
            loginMode = false;
            Log.i("Login mode switched to", "false; login mode");
            loginButton.setText("LOGIN");
            switchTextView.setText("Don't have an account? Sign up here");
            nameEditText.setVisibility(View.GONE);
        }
    }

    public void loginOrSignup(View view) {
        loginButton.setEnabled(false);
        email = emailEditText.getText().toString();
        password = passwordEditText.getText().toString();
        name = nameEditText.getText().toString();

        if (loginMode) {
            if (email.matches("") || password.matches("") || name.matches("")) {
                Toast.makeText(this, "Please enter email, password and a display name", Toast.LENGTH_SHORT).show();
            } else {
                //SIGNUP USER
                ParseUser user = new ParseUser();
                user.setUsername(email);
                user.setPassword(password);
                user.put("displayName", name);
                user.signUpInBackground(new SignUpCallback() {
                    @Override
                    public void done(ParseException e) {
                        if (e == null) {
                            Toast.makeText(MainActivity.this, "Successfully created new user", Toast.LENGTH_SHORT).show();
                            moveToInitialMenu();
                        } else {
                            e.printStackTrace();
                            Toast.makeText(MainActivity.this, "Sign Up failed: " + e.getMessage(), Toast.LENGTH_LONG).show();
                            loginButton.setEnabled(true);
                        }
                    }
                });
            }
        } else {
            if (email.matches("") || password.matches("")) {
                Toast.makeText(this, "Please enter email and password", Toast.LENGTH_SHORT).show();
            } else {
                //LOGIN USER
                ParseUser.logInInBackground(email, password, new LogInCallback() {
                    @Override
                    public void done(ParseUser user, ParseException e) {
                        if (e == null) {
                            Toast.makeText(MainActivity.this, "Login successful", Toast.LENGTH_SHORT).show();
                            moveToInitialMenu();
                        } else {
                          loginButton.setEnabled(true);
                          e.printStackTrace();
                            Toast.makeText(MainActivity.this, "Login failed: " + e.getMessage(), Toast.LENGTH_LONG).show();
                        }
                    }
                });
            }
        }

    }

    public void moveToInitialMenu() {
        Intent intent = new Intent(getApplicationContext(), InitialMenuActivity.class);
        startActivity(intent);
    }

}

主活动.xml:

<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:id="@+id/backgroundLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="@drawable/backgroundv1"
    tools:context=".MainActivity">

    <Button
        android:id="@+id/loginButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:fontFamily="@font/delius"
        android:onClick="loginOrSignup"
        android:paddingLeft="20dp"
        android:paddingRight="20dp"
        android:text="LOG IN"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.495"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/nameEditText" />

    <EditText
        android:id="@+id/emailEditText"
        android:layout_width="250dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="290dp"
        android:ems="10"
        android:fontFamily="@font/delius"
        android:hint="Email address"
        android:inputType="textEmailAddress"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.502"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <EditText
        android:id="@+id/passwordEditText"
        android:layout_width="250dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:ems="10"
        android:fontFamily="@font/delius"
        android:hint="Password"
        android:inputType="textPassword"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.502"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/emailEditText" />

    <EditText
        android:id="@+id/nameEditText"
        android:layout_width="250dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:ems="10"
        android:fontFamily="@font/delius"
        android:hint="Name (to display to others)"
        android:inputType="textPersonName"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/passwordEditText" />

    <TextView
        android:id="@+id/switchTextView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="4dp"
        android:fontFamily="@font/delius"
        android:onClick="switchToSignup"
        android:text="Don't have an account yet? Sign up here instead"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.495"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/loginButton" />
</android.support.constraint.ConstraintLayout>
r8uurelv

r8uurelv1#

在调试中将minifyenabled设置为true。也许minifyenabled删除了一些不应该删除的代码。因为它似乎在模拟器上运行良好。然后在本地调试代码。

buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

相关问题