AndroidManifest:
Код: Выделить всё
Код: Выделить всё
plugins {
alias(libs.plugins.android.application)
id("com.google.gms.google-services")
}
android {
namespace = "com.example.cerebrospinal"
compileSdk = 34
defaultConfig {
applicationId = "com.example.cerebrospinal"
minSdk = 24
targetSdk = 34
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
dependencies {
implementation(platform("com.google.firebase:firebase-bom:33.5.1"))
implementation("com.google.firebase:firebase-analytics")
// Firestore
implementation("com.google.firebase:firebase-firestore:25.1.1")
// Other Firebase/Play services deps
implementation("com.google.firebase:firebase-auth:21.0.1")
implementation("com.google.android.gms:play-services-auth:21.2.0")
// FirebaseUI (for authentication)
implementation("com.firebaseui:firebase-ui-auth:8.0.0")
implementation(libs.appcompat)
implementation(libs.material)
implementation(libs.activity)
implementation(libs.constraintlayout)
testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
}
Код: Выделить всё
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
id("com.google.gms.google-services") version "4.4.2" apply false
}
Код: Выделить всё
oneButton = findViewById(R.id.button1);
oneButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (sudokuController.getPencilMode() && sudokuController.getSelectedRow() > 0
&& sudokuController.getSelectedColumn() > 0) {
sudokuController.setSelectedNumber(1);
sudokuController.setBoardTile();
sudokuBoard.invalidate();
}
FirebaseFirestore db = FirebaseFirestore.getInstance();
// Create a new user with a first and last name
Map user = new HashMap();
user.put("first", "Ada");
user.put("last", "Lovelace");
user.put("born", 1815);
// Add a new document with a generated ID
db.collection("users")
.add(user)
.addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(DocumentReference documentReference) {
Log.d(TAG, "DocumentSnapshot added with ID: " + documentReference.getId());
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "Error adding document", e);
}
});
// Create a new user with a first, middle, and last name
user = new HashMap();
user.put("first", "Alan");
user.put("middle", "Mathison");
user.put("last", "Turing");
user.put("born", 1912);
// Add a new document with a generated ID
db.collection("users")
.add(user)
.addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(DocumentReference documentReference) {
Log.d(TAG, "DocumentSnapshot added with ID: " + documentReference.getId());
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.w(TAG, "Error adding document", e);
}
});
db.collection("users")
.get()
.addOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
Log.d(TAG, document.getId() + " => " + document.getData());
}
} else {
Log.w(TAG, "Error getting documents.", task.getException());
}
}
});
}
});
Код: Выделить всё
2024-11-14 19:37:17.284 9790-9849 ProfileInstaller com.example.cerebrospinal D Installing profile for com.example.cerebrospinal
2024-11-14 19:37:19.383 9790-9809 EGL_emulation com.example.cerebrospinal D app_time_stats: avg=304.30ms min=13.14ms max=3634.54ms count=13
2024-11-14 19:37:19.620 9790-9790 ContentValues com.example.cerebrospinal D ArTLEmYycQ7AkM3Autjg => {middle=Mathison, last=Turing, born=1912, first=Alan}
2024-11-14 19:37:19.620 9790-9790 ContentValues com.example.cerebrospinal D JUIWkKMuC3wWTimIDdmP => {last=Lovelace, born=1815, first=Ada}
2024-11-14 19:37:19.620 9790-9790 ContentValues com.example.cerebrospinal D LQ1tECj91ivvL7ZhF7i8 => {last=Lovelace, born=1815, first=Ada}
2024-11-14 19:37:19.620 9790-9790 ContentValues com.example.cerebrospinal D xAmdrpHnykJarOA4ibt0 => {middle=Mathison, last=Turing, born=1912, first=Alan}
2024-11-14 19:37:19.724 9790-9790 ContentValues com.example.cerebrospinal D DocumentSnapshot added with ID: LQ1tECj91ivvL7ZhF7i8
2024-11-14 19:37:19.756 9790-9790 ContentValues com.example.cerebrospinal D DocumentSnapshot added with ID: xAmdrpHnykJarOA4ibt0
2024-11-14 19:37:25.332 9790-9840 GoogleApiManager com.example.cerebrospinal E Failed to get service from broker. (Ask Gemini)
java.lang.SecurityException: Unknown calling package name 'com.google.android.gms'.
at android.os.Parcel.createExceptionOrNull(Parcel.java:3242)
at android.os.Parcel.createException(Parcel.java:3226)
at android.os.Parcel.readException(Parcel.java:3209)
at android.os.Parcel.readException(Parcel.java:3151)
at amxe.a(:com.google.android.gms@244337038@24.43.37 (260800-693941914):36)
at amvl.z(:com.google.android.gms@244337038@24.43.37 (260800-693941914):143)
at amcs.run(:com.google.android.gms@244337038@24.43.37 (260800-693941914):54)
at android.os.Handler.handleCallback(Handler.java:959)
at android.os.Handler.dispatchMessage(Handler.java:100)
at bskq.mC(:com.google.android.gms@244337038@24.43.37 (260800-693941914):1)
at bskq.dispatchMessage(:com.google.android.gms@244337038@24.43.37 (260800-693941914):5)
at android.os.Looper.loopOnce(Looper.java:232)
at android.os.Looper.loop(Looper.java:317)
at android.os.HandlerThread.run(HandlerThread.java:85)
2024-11-14 19:42:19.801 9790-9867 TrafficStats com.example.cerebrospinal D tagSocket(136) with statsTag=0xffffffff, statsUid=-1
2024-11-14 19:42:19.881 9790-9867 TrafficStats com.example.cerebrospinal D tagSocket(5) with statsTag=0xffffffff, statsUid=-1
Подробнее здесь: https://stackoverflow.com/questions/791 ... from-it-an