这里是我的code:
import android.app.Application;
import android.os.Bundle;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;
import java.util.List;
import cn.leancloud.AVOSCloud;
import cn.leancloud.AVObject;
import cn.leancloud.AVQuery;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;
public class MainActivity extends AppCompatActivity {
public class MyLeanCloudApp extends Application {
@Override
public void onCreate() {
super.onCreate();
// 提供 this、App ID、App Key、Server Host 作为参数
// 注意这里千万不要调用 cn.leancloud.core.AVOSCloud 的 initialize 方法,否则会出现 NetworkOnMainThread 等错误。
AVOSCloud.initialize(this, "abcdefg", "abcdefg", "abcdefg");
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}
public void onBtnClick (View view){
AVObject testObject = new AVObject("TestObject");
testObject.put("words", "Hello android!");
testObject.saveInBackground().blockingSubscribe();
TextView txtHello = findViewById(R.id.txtMessage);
txtHello.setText("got me!");
}
gradle应该是没有问题的,可是我这样每次一点按钮程序就闪退了,还总说missing app id。有大神可以帮我看一下嘛,是不是我配置的有问题呀,谢谢!!!!感恩!!!!