2017-02-21 21 views
-1

Когда я пытаюсь запустить свое приложение, «к сожалению», приложение «остановилось» на экране. Я исследовал эту проблему и пытался изменить код в файле манифеста. Кроме того, я пробовал многократно очищать проект, восстанавливать проект, недействить кеш и перезапускать вариант, но это также не помогает в решении проблемы.Android Studio: К сожалению приложение остановилось

Здесь ошибка показано в моем LogCat

02-21 09:26:52.695 3123-3123/? E/memtrack: Couldn't load memtrack module (No such file or directory) 
02-21 09:26:52.695 3123-3123/? E/android.os.Debug: failed to load memtrack module: -2 
02-21 09:26:56.587 3137-3137/? E/memtrack: Couldn't load memtrack module (No such file or directory) 
02-21 09:26:56.587 3137-3137/? E/android.os.Debug: failed to load memtrack module: -2 
02-21 09:26:57.611 3147-3147/com.example.nobelz.chatapp E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering 
02-21 09:26:58.231 3147-3147/com.example.nobelz.chatapp E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from GradienCache 
02-21 09:26:58.235 3147-3147/com.example.nobelz.chatapp E/OpenGLRenderer: MAX_TEXTURE_SIZE: 8192 
02-21 09:26:58.259 3147-3147/com.example.nobelz.chatapp E/OpenGLRenderer: Getting MAX_TEXTURE_SIZE from Caches::initConstraints() 
02-21 09:26:58.263 3147-3147/com.example.nobelz.chatapp E/OpenGLRenderer: MAX_TEXTURE_SIZE: 8192 
02-21 09:27:02.323 3147-3147/com.example.nobelz.chatapp E/AndroidRuntime: FATAL EXCEPTION: main 
Process: com.example.nobelz.chatapp, PID: 3147 
com.google.firebase.database.DatabaseException: Class  com.example.nobelz.chatapp.ChatMessage is missing a constructor with no arguments 
                      at com.google.android.gms.internal.zzbqi$zza.zze(Unknown Source) 
                      at com.google.android.gms.internal.zzbqi$zza.zzaG(Unknown Source) 
                      at com.google.android.gms.internal.zzbqi.zze(Unknown Source) 
                      at com.google.android.gms.internal.zzbqi.zzb(Unknown Source) 
                      at com.google.android.gms.internal.zzbqi.zza(Unknown Source) 
                      at com.google.firebase.database.DataSnapshot.getValue(Unknown Source) 
                      at com.firebase.ui.database.FirebaseListAdapter.parseSnapshot(FirebaseListAdapter.java:127) 
                      at com.firebase.ui.database.FirebaseListAdapter.getItem(FirebaseListAdapter.java:116) 
                      at com.firebase.ui.database.FirebaseListAdapter.getView(FirebaseListAdapter.java:146) 
                      at android.widget.AbsListView.obtainView(AbsListView.java:2255) 
                      at android.widget.ListView.makeAndAddView(ListView.java:1790) 
                      at android.widget.ListView.fillDown(ListView.java:691) 
                      at android.widget.ListView.fillFromTop(ListView.java:752) 
                      at android.widget.ListView.layoutChildren(ListView.java:1616) 
                      at android.widget.AbsListView.onLayout(AbsListView.java:2087) 
                      at android.view.View.layout(View.java:14817) 
                      at android.view.ViewGroup.layout(ViewGroup.java:4631) 
                      at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055) 
                      at android.view.View.layout(View.java:14817) 
                      at android.view.ViewGroup.layout(ViewGroup.java:4631) 
                      at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) 
                      at android.widget.FrameLayout.onLayout(FrameLayout.java:388) 
                      at android.view.View.layout(View.java:14817) 
                      at android.view.ViewGroup.layout(ViewGroup.java:4631) 
                      at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:437) 
                      at android.view.View.layout(View.java:14817) 
                      at android.view.ViewGroup.layout(ViewGroup.java:4631) 
                      at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) 
                      at android.widget.FrameLayout.onLayout(FrameLayout.java:388) 
                      at android.view.View.layout(View.java:14817) 
                      at android.view.ViewGroup.layout(ViewGroup.java:4631) 
                      at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671) 
                      at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525) 
                      at android.widget.LinearLayout.onLayout(LinearLayout.java:1434) 
                      at android.view.View.layout(View.java:14817) 
                      at android.view.ViewGroup.layout(ViewGroup.java:4631) 
                      at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) 
                      at android.widget.FrameLayout.onLayout(FrameLayout.java:388) 
                      at android.view.View.layout(View.java:14817) 
                      at android.view.ViewGroup.layout(ViewGroup.java:4631) 
                      at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1983) 
                      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1740) 
                      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996) 
                      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600) 
                      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) 
                      at android.view.Choreographer.doCallbacks(Choreographer.java:574) 
                      at android.view.Choreographer.doFrame(Choreographer.java:544) 
                      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747) 
                      at android.os.Handler.handleCallback(Handler.java:733) 
                      at android.os.Handler.dispatchMessage(Handler.java:95) 
                      at android.os.Looper.loop(Looper.java:136) 
                      at android.app.ActivityThread.main(ActivityThread.java:5001) 
                      at java.lang.reflect.Method.invokeNative(Native Method) 
                      at java.lang.reflect.Method.invoke(Method.java:515) 
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) 
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) 
                      at dalvik.system.NativeStart.main(Native Method) 
02-21 09:27:07.367 560-593/system_process E/InputDispatcher: channel '52c1f3d8 com.example.nobelz.chatapp/com.example.nobelz.chatapp.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed! 
02-21 09:31:38.407 232-232/? E/Drm: Failed to open plugin directory /vendor/lib/mediadrm 
02-21 09:32:05.543 859-1264/com.google.process.gapps E/dalvikvm: Could not find class 'android.net.Network', referenced from method qlb.a 
02-21 09:34:38.537 859-1421/com.google.process.gapps E/NetworkScheduler: Called closeAndCleanupTask for already completed task [com.google.android.apps.maps/com.google.android.apps.gmm.offline.OfflineAutoUpdateGcmService:OfflineAutoUpdateGcmService.TASK_TAG,u0]' :TIMED_OUT 
02-21 09:34:38.573 859-1421/com.google.process.gapps E/NetworkScheduler: Task completed but with no record in list of active tasks: [com.google.android.apps.maps/com.google.android.apps.gmm.offline.OfflineAutoUpdateGcmService:OfflineAutoUpdateGcmService.TASK_TAG,u0] 
02-21 09:34:40.793 3391-3391/? E/dalvikvm: Could not find class 'javax.net.ssl.SNIHostName', referenced from method com.google.android.gms.org.conscrypt.Platform.getSSLParameters 
02-21 09:34:40.797 3391-3391/? E/dalvikvm: Could not find class 'javax.net.ssl.SNIServerName', referenced from method com.google.android.gms.org.conscrypt.Platform.setSSLParameters 
02-21 09:34:40.805 3391-3391/? E/dalvikvm: Could not find class 'com.google.android.gms.org.conscrypt.OpenSSLExtendedSessionImpl', referenced from method com.google.android.gms.org.conscrypt.Platform.wrapSSLSession 
02-21 09:34:40.833 725-725/com.google.android.gms.persistent E/ChimeraRcvrProxy: Chimera config error: com.google.android.chimera.config.InvalidConfigException: No registered Chimera receiver impl for ComponentInfo{com.google.android.gms/com.google.android.gms.phenotype.receiver.PhenotypeBroadcastReceiver} 
02-21 09:34:40.833 725-725/com.google.android.gms.persistent E/ChimeraRcvrProxy: com.google.android.gms.phenotype.receiver.PhenotypeBroadcastReceiver dropping broadcast com.google.android.gms.phenotype.UPDATE 
02-21 09:34:40.913 3391-3391/? E/dalvikvm: Could not find class 'com.google.android.gms.org.conscrypt.OpenSSLExtendedSessionImpl', referenced from method com.google.android.gms.org.conscrypt.SSLParametersImpl.getSessionToReuse 
02-21 09:34:41.169 725-725/com.google.android.gms.persistent E/BluetoothAdapter: Bluetooth binder is null 
02-21 09:34:41.645 725-725/com.google.android.gms.persistent E/BluetoothAdapter: Bluetooth binder is null 
02-21 09:34:41.709 725-3425/com.google.android.gms.persistent E/GCoreUlr: Bad errorId configuring silent feedback 
02-21 09:34:41.937 725-725/com.google.android.gms.persistent E/BluetoothAdapter: Bluetooth binder is null 
02-21 09:34:42.013 725-1235/com.google.android.gms.persistent E/GCoreUlr: Bad errorId configuring silent feedback 
02-21 09:34:42.069 725-725/com.google.android.gms.persistent E/BluetoothAdapter: Bluetooth binder is null 
02-21 09:34:42.161 725-1235/com.google.android.gms.persistent E/GCoreUlr: Bad errorId configuring silent feedback 
02-21 09:34:42.265 725-1235/com.google.android.gms.persistent E/GCoreUlr: Bad errorId configuring silent feedback 
02-21 09:34:42.309 725-1235/com.google.android.gms.persistent E/GCoreUlr: Bad errorId configuring silent feedback 
02-21 09:35:10.173 560-567/system_process E/dalvikvm: JIT code cache full 
+2

он говорит «отсутствует конструктор без аргументов» –

ответ

0

В классе ChatMessage добавить конструктор без параметров:

public ChatMessage() { 
    //Do things 
} 
+0

я должен использовать конструктор внутри ChatMessage, даже если он оленья кожа работа. –

+0

Я предполагаю, что ошибка не то же самое. – tilz0R

+0

Я предоставил код ..... и я тоже использую конструктор .... используя конструктор, он показывал эти ошибки .... –

0

Часть с застройщиком, безусловно, самое главное: это, кажется, вы отсутствует:

com.google.firebase.database.DatabaseException: Class  com.example.nobelz.chatapp.ChatMessage is missing a constructor with no arguments 

Предлагаю вам переписать свое кодовое объявление одновременно, чтобы вы могли изолировать свою проблему и решить ее.

+0

Какую функцию мне пришлось бы добавить ..... в соответствии с базой данных компилировать «com.firebaseui: firebase-ui: 1.1.1» в моих зависимостях –

0

Это мой код, но при этом он показывает ту же ошибку.

Вот код manidest.xml:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
package="com.example.nobelz.chatapp"> 

<!-- add tools:replace="android:supportsRtl" on application because android:supportsRtl="true" is also defined 
in compile 'com.firebaseui:firebase-ui:1.1.1' --> 

<application 
    tools:replace="android:supportsRtl" 
    android:allowBackup="true" 
    android:fullBackupContent="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:roundIcon="@mipmap/ic_launcher_round" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 
    <activity android:name=".MainActivity"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <action android:name="android.intent.action.VIEW"/> 
      <data android:scheme="@string/app_name" android:host="com.example.nobelz.ChatApp" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
    </activity> 
</application> 

</manifest> 

Вот Gradle: код приложения:

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 25 
buildToolsVersion "25.0.2" 
defaultConfig { 
    applicationId "com.example.nobelz.chatapp" 
    minSdkVersion 16 
    multiDexEnabled true 
    targetSdkVersion 25 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
} 

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

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' 
}) 

//add library 

compile 'com.android.support:appcompat-v7:25.1.0' 
compile 'com.android.support:recyclerview-v7:25.1.0' 
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4' 
compile 'com.android.support:design:25.1.0' 
compile 'com.firebaseui:firebase-ui:1.1.1' 
compile 'com.google.android.gms:play-services-auth:10.0.1' 
testCompile 'junit:junit:4.12' 
} 
apply plugin: 'com.google.gms.google-services' 

Вот Основной класс активность:

package com.example.nobelz.chatapp; 

import android.content.Intent; 
import android.support.annotation.NonNull; 
import android.support.design.widget.FloatingActionButton; 
import android.support.v7.app.AppCompatActivity; 
import android.os.Bundle; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.View; 
import android.widget.EditText; 
import android.widget.ListView; 
import android.widget.RelativeLayout; 
import android.widget.TextView; 
import android.widget.Toast; 

import com.firebase.ui.auth.AuthUI; 
import com.firebase.ui.database.FirebaseListAdapter; 
import com.google.android.gms.tasks.OnCompleteListener; 
import com.google.android.gms.tasks.Task; 
import com.google.firebase.auth.FirebaseAuth; 
import com.google.firebase.database.FirebaseDatabase; 

import android.text.format.DateFormat; 

public class MainActivity extends AppCompatActivity { 

private static int SIGN_IN_REQUEST_CODE = 1; 
private FirebaseListAdapter<ChatMessage> adapter; 
RelativeLayout activity_main; 
FloatingActionButton fab; 

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

    activity_main = (RelativeLayout)findViewById(R.id.activity_main); 

//  check if not sign in then navigate sign page 
if(FirebaseAuth.getInstance().getCurrentUser() == null){ 
    startActivityForResult(
      AuthUI.getInstance(). 
      createSignInIntentBuilder().build(), 
      SIGN_IN_REQUEST_CODE 
    ); 
} else { 
//  User is already sign in..Display a welcome toasr 
//  a welcome toast 

    Toast.makeText(this,"Welcome " + FirebaseAuth.getInstance() 
       .getCurrentUser() 
       .getDisplayName(), 
        Toast.LENGTH_LONG) 
        .show(); 
//  Load chat rooms content 

    displayChatmessage(); 
} 

    fab = (FloatingActionButton)findViewById(R.id.fab); 

    fab.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 
      EditText input = (EditText)findViewById(R.id.input); 

//    read the input field and push a new instance 
//    of chat message to the firebase database 

      FirebaseDatabase.getInstance() 
        .getReference() 
        .push() 
        .setValue(new ChatMessage(input.getText().toString(), 
          FirebaseAuth.getInstance() 
        .getCurrentUser() 
        .getDisplayName()) 
        ); 

//    clear the input 

      input.setText(" "); 

     } 
    }); 

} 


@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    getMenuInflater().inflate(R.menu.main_menu, menu); 
    return true; 
} 

private void displayChatmessage() { 

    ListView listOfMessages = (ListView)findViewById(R.id.list_of_message); 

    adapter = new FirebaseListAdapter<ChatMessage>(this, ChatMessage.class,R.layout.lixt_item, FirebaseDatabase.getInstance().getReference()) { 
     @Override 
     protected void populateView(View v, ChatMessage model, int position)  { 
      //get reference to the view of message.xml 
      TextView messageText = (TextView)v.findViewById(R.id.message_text); 
      TextView messageUser = (TextView)v.findViewById(R.id.message_user); 
      TextView messageTime = (TextView)v.findViewById(R.id.message_time); 

//    set their text 

      messageText.setText(model.getMessageText()); 
      messageUser.setText(model.getMessageUser()); 

//    Format the date before using it 

     messageTime.setText(DateFormat.format("dd-MM-yyyy (HH:mm:ss)",model.getMessageTime())); 

     } 
     }; 

    listOfMessages.setAdapter(adapter); 
} 


@Override 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    super.onActivityResult(requestCode, resultCode, data); 

    if(requestCode == SIGN_IN_REQUEST_CODE){ 
     if(resultCode == RESULT_OK){ 
      Toast.makeText(this, "Sucessfully Sign in. Welcome! ", 
        Toast.LENGTH_LONG).show(); 

//    close the app 
      finish(); 

     } 
    } 

} 


@Override 
public boolean onOptionsItemSelected(MenuItem item) { 
    if(item.getItemId() == R.id.menu_sign_out){ 
     AuthUI.getInstance().signOut(this) 
     .addOnCompleteListener(new OnCompleteListener<Void>() { 
      @Override 
      public void onComplete(@NonNull Task<Void> task) { 
       Toast.makeText(MainActivity.this, "You hav been signed out.", Toast.LENGTH_LONG).show(); 


//     close activity 
       finish(); 

      } 
     }); 
    } 

    return true; 
} 
} 

Вот Класс ChatMessage;

package com.example.nobelz.chatapp; 

import java.util.Date; 

public class ChatMessage { 
private String messageText; 
private String messageUser; 
private long messageTime; 


public ChatMessage(String messageText, String messageUser) { 
    this.messageText = messageText; 
    this.messageUser = messageUser; 

    messageTime = new Date().getTime(); 
} 

public String getMessageText() { 
    return messageText; 
} 

public void setMessageText(String messageText) { 
    this.messageText = messageText; 
} 

public String getMessageUser() { 
    return messageUser; 
} 

public void setMessageUser(String messageUser) { 
    this.messageUser = messageUser; 
} 

public long getMessageTime() { 
    return messageTime; 
} 

public void setMessageTime(long messageTime) { 
    this.messageTime = messageTime; 
} 


} 
+0

Я знал это! Я не вижу конструктор по умолчанию без аргументов в вашем коде! – tilz0R

+0

Не могли бы вы рассказать мне код конструктора по умолчанию. –

+0

Проверьте мой первый ответ @Sushank. – tilz0R