此错误是什么意思,我该如何解决?
“无法在单个dex中容纳请求的类 文件(#方法:86421> 65536)”和
原因:com.android.tools.r8.CompilationFailedException:编译无法完成
我正在尝试将数据库连接到我的应用程序, 在控制台中收到此错误,我不知道该怎么办。我也使用firebase作为数据库。
这是我的 build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.tastebuds"
minSdkVersion 17
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
//multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.google.firebase:firebase-firestore:21.3.0'
implementation 'com.google.firebase:firebase-storage:19.1.0'
implementation 'com.google.firebase:firebase-database:19.2.0'
//implementation 'com.android.support:multidex:1.0.3'
}
apply plugin: 'com.google.gms.google-services'
这是我的 CreateProfile
package com.example.tastebuds;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
public class CreateProfile extends AppCompatActivity {
EditText CPFname, CPLname, DOB, CPstate, CPcity, CPzip, CPbio;
ImageButton savebtn, cambtn;
ImageView pic;
FirebaseDatabase database;
DatabaseReference ref;
User user;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_profile);
CPFname = (EditText) findViewById(R.id.CPFname);
CPLname = (EditText) findViewById(R.id.CPLname);
DOB = (EditText) findViewById(R.id.DOB);
CPstate = (EditText) findViewById(R.id.CPstate);
CPcity = (EditText) findViewById(R.id.CPcity);
CPzip = (EditText) findViewById(R.id.CPzipcode);
CPbio = (EditText) findViewById(R.id.CPbio);
savebtn = (ImageButton) findViewById(R.id.CPsavebtn);
cambtn = (ImageButton) findViewById(R.id.CPcamera);
pic = (ImageView) findViewById(R.id.CPprofilepic);
database = FirebaseDatabase.getInstance();
ref = database.getReference("users");
user = new User();
}
private void getValues()
{
user.setFirstName(CPFname.getText().toString());
user.setLastName(CPLname.getText().toString());
user.setDOB(DOB.getText().toString());
user.setcity(CPcity.getText().toString());
user.setstate(CPstate.getText().toString());
user.setzip(CPzip.getText().toString());
user.setbio(CPbio.getText().toString());
}
public void savebtn(View view)
{
ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
ref.child("users03").setValue(user);
getValues();
Toast.makeText(CreateProfile.this, "Data is inserted....",
Toast.LENGTH_SHORT).show();
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
// savebtn.setOnClickListener(new View.OnClickListener)
// Intent intoHomeFeed = new Intent(CreateProfile.this, HomeFeed.class);
// startActivity(intoHomeFeed);
}