[related code for error in MainActivity.kt][2]
I have tried fn+option+return(Mac IOS) for import purpose, but still not working. Same as trying invalidate caches and restart. They are not working!
I just follow the lecture which is given by the professor step by step. The version for the Android studio on my macbook is 3.5.1
Looking for help.
I also met another error. Here is the code for the AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.assignment3muyaozhang0882423" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
android:value="#integer/google_play_services_version" />
<activity android:name=".Floating_label" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" >
</activity>
</application>
</manifest>
The error I met which is sync error:
ERROR: Failed to parse XML in /Users/kitty/Downloads/Assignment2MuyaoZhang0882423/app/src/main/AndroidManifest.xml
org.xml.sax.SAXParseException; systemId: file:/Users/kitty/Downloads/Assignment2MuyaoZhang0882423/app/src/main/AndroidManifest.xml; lineNumber: 23; columnNumber: 4; 元素类型 "manifest" 必须由匹配的结束标记 "" 终止。
Affected Modules: app
The code for app:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.assignment3muyaozhang0882423"
minSdkVersion 14
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = kotlin_version
targetCompatibility = kotlin_version
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.android.support:design:29.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
code for kt file:
package com.example.assignment3muyaozhang0882423
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.R
import android.widget.Toast
import android.widget.Toast.LENGTH_LONG
import android.widget.Toast.makeText
class setion2 : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_setion2)
val usernamestring = text_Person_Name.text
val passwordstring = text_Password.text
val con_btn = (Button) findViewById(R.id.con_btn) as Button
con_btn.isAllCaps = false
con_btn.setOnClickListener {
if (this.usernamestring.isNotEmpty() && this.passwordstring.isNotEmpty())
{
val message =
"User Name: " + usernamestring + "\n" + "Password: " + this.passwordstring
Toast.makeText(this, message, LENGTH_LONG).show()
} else {
Toast.makeText(this, "Please enter valid input", LENGTH_LONG).show()
}
}
}
}
Please check out my reply on your comment too.
Click on the error of text_layout and send the relevant code.
It is LinearLayout.LayoutParams.MATCH_PARENT
the underscore is missing between MATCH and PARENT
Related
When I try to rebuild project, android studio gives the error: I couldn't solve this problem for 2 days please help. What changes should I make?
``Execution failed for task ':app:processDebugManifest'.
I tried all solutions provided for similar problems like this one:
enter link description here
enter link description here
my build gradle
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/'}
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven { url 'https://maven.google.com' }
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
//the compression of webp file during build causes problem with FileDescriptor in ContentProvider.
aaptOptions {
noCompress "webp"
}
signingConfigs {
signing_config {
keyAlias 'abc'
keyPassword '123'
}
}
compileSdkVersion 28
defaultConfig {
applicationId "com.whatsapp.fenerstickers"
minSdkVersion 18
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
def contentProviderAuthority = applicationId + ".stickercontentprovider"
// Creates a placeholder property to use in the manifest.
manifestPlaceholders =
[
onesignal_app_id: 'XXXXXXX',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE'
]
[contentProviderAuthority: contentProviderAuthority]
// Adds a new field for the authority to the BuildConfig class.
buildConfigField("String",
"CONTENT_PROVIDER_AUTHORITY",
"\"${contentProviderAuthority}\"")
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
task checkDebug {
doLast {
println("checkDebug")
if (android.defaultConfig.applicationId.startsWith("com.whatsapp")) {
throw new GradleException("applicationId in defaultConfig cannot start with com.whatsapp, please change your applicationId in app/build.gradle");
}
checkApplicationIdInDebug()
}
}
private void checkApplicationIdInDebug() {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def ignoreApplicationIdCheck = properties.getProperty('ignoreApplicationIdCheck')
if (ignoreApplicationIdCheck == null) {
} else {
println("application id check ignored")
}
}
task checkRelease {
doLast {
println("checkRelease")
if (android.defaultConfig.applicationId.startsWith("com.example")) {
throw new GradleException("applicationId in defaultConfig cannot start with com.example, please change your applicationId in app/build.gradle");
}
}
}
tasks.whenTaskAdded { task ->
println(task.name)
if (task.name.contains("assembleDebug")) {
task.dependsOn checkDebug
}
if (task.name.contains("assembleRelease")) {
task.dependsOn checkRelease
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.facebook.fresco:fresco:1.10.0'
implementation 'com.facebook.fresco:webpsupport:1.10.0'
implementation 'com.facebook.fresco:animated-webp:1.10.0'
implementation 'com.facebook.fresco:webpsupport:1.10.0'
implementation 'com.google.android.gms:play-services-ads:11.8.0'
implementation 'com.google.firebase:firebase-ads:11.8.0'
implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
}
my manifests
<?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.main.berk">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<application
android:allowBackup="false"
android:fullBackupContent="false"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
<activity android:name=".EntryActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".StickerPackListActivity"
android:label="#string/title_activity_sticker_packs_list" />
<activity
android:name=".StickerPackDetailsActivity"
android:parentActivityName=".StickerPackListActivity"
tools:ignore="UnusedAttribute">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.main.berk.StickerPackListActivity" />
</activity>
<activity
android:name=".StickerPackInfoActivity"
android:label="#string/title_activity_sticker_pack_info"
android:parentActivityName=".StickerPackDetailsActivity"
tools:ignore="UnusedAttribute">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.main.berk.StickerPackDetailsActivity" />
</activity>
<provider
android:name=".StickerContentProvider"
android:authorities="${contentProviderAuthority}"
android:enabled="true"
android:exported="true"
android:readPermission="com.whatsapp.sticker.READ" />
</application>
</manifest>
Merging Errors:
Error: Attribute provider#com.main.berk.StickerContentProvider#authorities at AndroidManifest.xml:48:13-62 requires a placeholder substitution but no value for <contentProviderAuthority> is provided. app main manifest (this file), line 47 Error: Validation failed, exiting app main manifest (this file)
You just need to combine multiple array of manifestPlaceholders in one like this
manifestPlaceholders =
[
// WhatsApp Placeholder
contentProviderAuthority: contentProviderAuthority,
onesignal_app_id: 'XXXXXXX',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE'
]
I have problem with Fabric. its a test project for find problem and do everything step by step in fabric documents, but i don't know what is mistake. please help me.
My Gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.mycompany.testtt"
minSdkVersion 17
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile('com.crashlytics.sdk.android:crashlytics:2.9.4#aar') {
transitive = true;
}
}
My Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.testtt">
<application
android:allowBackup="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" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="9fd0b323bad2f5dae063288c94fd3a2317faa104"
/>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Main Activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
// TODO: Move this to where you establish a user session
logUser();
setContentView(R.layout.activity_main);
}
private void logUser() {
// TODO: Use the current user's information
// You can call any combination of these three methods
Crashlytics.setUserIdentifier("12345");
Crashlytics.setUserEmail("user#fabric.io");
Crashlytics.setUserName("Test User");
}
public void forceCrash(View view) {
throw new RuntimeException("This is a crash");
}
After all, and error and testing, but nothing is still displayed on the dashboard.
I do everything step by step from fabric documents.
I have this problem for a few days, and anyway I've tested it, but I still have not gotten a result and does not display anything in the fabric dashboard. ApiKey is correct and I'm sure of it.
(sorry for English)
I need a database in my app and I chose SugarORM. But I can't even run a simple example. I have NullPointerException when I use save() method.
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.aleksandr.birukov.myapplication"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile 'com.android.support:support-annotations:27.1.1'
compile 'com.github.satyan:sugar:1.4'
}
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.aleksandr.birukov.myapplication">
<application
android:allowBackup="true"
android:name="com.orm.SugarApp"
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" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="DATABASE"
android:value="notes.db" />
<meta-data
android:name="VERSION"
android:value="1" />
<meta-data
android:name="QUERY_LOG"
android:value="true" />
<meta-data
android:name="DOMAIN_PACKAGE_NAME"
android:value="com.aleksandr.birukov.myapplication" />
</application>
</manifest>
Note.java
package com.aleksandr.birukov.myapplication;
import com.orm.SugarRecord;
public class Note extends SugarRecord {
String title, note;
long time;
public Note() {
}
public Note(String title, String note, long time) {
this.title = title;
this.note = note;
this.time = time;
}
}
MainActivity.java
package com.aleksandr.birukov.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Note note = new Note("title", "desc", 100);
note.save();
}
}
I don't understand what I did wrong?
Make your class extend SugarRecord< Note >
I have update Android Studio to the new Canary version, and I updated my gradle file. When I launch my app through run, I get the following error:
Process: io.github.siddharthvenu.saltanalysis, PID: 23244
java.lang.SecurityException: Signature check failed for io.github.siddharthvenu.saltanalysis
at android.os.Parcel.readException(Parcel.java:1915)
at android.os.Parcel.readException(Parcel.java:1861)
at com.google.android.gms.common.internal.zzv$zza$zza.zza(Unknown Source:41)
at com.google.android.gms.common.internal.zzf.zza(Unknown Source:0)
at com.google.android.gms.internal.zzzf$zzc.zzxQ(Unknown Source:0)
at com.google.android.gms.internal.zzzf$zzf.run(Unknown Source:0)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at com.google.android.gms.internal.zzabx.run(Unknown Source:7)
at java.lang.Thread.run(Thread.java:764)
Edit: I found that the above error is caused due to AdView of Android. Somehow including ads in my app makes it crash.
I thought this was maybe because I didn't sign the apk, so I signed it (debug), and then tried to install it using adb install command. I got the following output:
Failed to install alpha_test_006.apk: Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]
My AndroidManifest:
<?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="io.github.siddharthvenu.saltanalysis">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:hardwareAccelerated="false"
android:icon="#mipmap/ic_material_chemical"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:ignore="AllowBackup">
<activity android:name=".HomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".RadicalListActivity"
android:parentActivityName=".HomeActivity"
android:theme="#style/AppTheme.TranslucentActionBar"
android:screenOrientation="sensorPortrait"
tools:targetApi="jelly_bean" />
<activity
android:name=".DisplayRadicalActivity"
android:parentActivityName=".RadicalListActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
tools:targetApi="jelly_bean" />
<activity
android:name=".GroupSeparationActivity"
android:parentActivityName=".HomeActivity"
android:screenOrientation="sensorLandscape"
tools:targetApi="jelly_bean" />
<activity
android:name=".LongProcedureActivity"
android:label="Long Procedure"
tools:targetApi="jelly_bean"/>
</application>
</manifest>
My build.gradle:app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-O'
buildToolsVersion '26.0.0-rc1'
def versionPropsFile = file('version.properties')
def code = 1
if (versionPropsFile.canRead()) {
Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
List<String> runTasks = gradle.startParameter.getTaskNames();
def value = 0
for (String item : runTasks)
if (item.contains("assembleRelease")) {
value = 1
}
code = versionProps['VERSION_CODE'].toInteger() + value
versionProps['VERSION_CODE'] = code.toString()
versionProps.store(versionPropsFile.newWriter(), null)
defaultConfig {
applicationId "io.github.siddharthvenu.saltanalysis"
minSdkVersion 15
targetSdkVersion 'O'
versionCode code
versionName "1.0 Alpha"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
} else {
throw new FileNotFoundException("Could not read version.properties!")
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig getSigningConfig()
def str_ver
if ((int) (code / 100) != 0) {
str_ver = String.valueOf(code)
} else if ((int) (code / 10) != 0) {
str_ver = "0" + String.valueOf(code)
} else {
str_ver = "00" + String.valueOf(code)
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFile = new File(output.outputFile.parent,
output.outputFile.name.replace(output.outputFile.name, "alpha_test_" + str_ver + ".apk")
)
}
}
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:cardview-v7:26.0.0-alpha1'
compile 'com.android.support:recyclerview-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
compile 'com.github.manuelpeinado.fadingactionbar:fadingactionbar-abc:3.1.2'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-ads:10.0.1'
compile 'com.jaredrummler:material-spinner:1.1.0'
compile 'com.google.code.findbugs:jsr305:2.0.1'
testCompile 'junit:junit:4.12'
compile files('libs/YouTubeAndroidPlayerApi.jar')
}
apply plugin: 'com.google.gms.google-services'
I found out the reason for the SecurityException generated in the first case. It was due to including an AdViewin my code. I tried to comment it out, and it worked. I suspected this because only activities which contained the AdView's crashed.
The adb install issue still persists though
I've created following project in Android Studio, and clicked on "Run" button in Android Studio to run the app.
In my mind, Android Studio will run the app with debug model, but what will Toast display? will it display the one of following options?
A: com.example.my.myapplication FLAVOR free
B: com.example.my.myapplication FLAVOR pro
C: info.dodata.messagecleanup FLAVOR free
D: info.dodata.messagecleanup FLAVOR pro
MainActivity.java
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String versionName = getPackageName()+" FLAVOR "+BuildConfig.FLAVOR;
if (BuildConfig.FLAVOR == "pro") {
Toast.makeText(getApplicationContext(), versionName, Toast.LENGTH_LONG).show();
}else{
Toast.makeText(getApplicationContext(), versionName , Toast.LENGTH_LONG).show();
}
}
}
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.my.myapplication"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
productFlavors {
free {
applicationId "info.dodata.messagecleanup"
}
pro {
applicationId "info.dodata.messagecleanup.pro"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.my.myapplication" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".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>
</application>
</manifest>