From Eclipse to android studio internet problems - android

So,I am importing a project that works perfectly (tested on 4 phones) from Eclipse to Android studio and when I run the application WITHOUT modifying anything at all, it won't allow me to use the internet at all.
As for code...it's pointless to post any ,because I created an application that does nothing but connect to a database and it still won't work, while the exact same code will work perfectly when I run the application from Eclipse to my phone. (Same phone by the way)
Just to make sure that won't be an answer: I HAVE the permissions added in my manifest.
Any suggestions?
//manifest.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="vlad.tests.com.udptextconnection" >
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<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>
// Build.gradle (module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "vlad.tests.com.udptextconnection"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
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'
}
//Build.gradle (project [project-name])
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}

Try putting permissions outside of application tag.

Not sure if it'd work but, try and clean your project.
Go to Build->Clean Project.
Try Build->Rebuild Project.

Related

Android - Set up Google Play Services and Firebase - Gradle build error

I'm having issues including Google services in my project.
The errors
Following these instructions, and also referring to the docs to set it up, I encounter a problem with the apply plugins property:
For reasons unbeknownst to me, it's not fetching correctly (something about the version being wrong) even though that property is auto-filled when you click on 'Add FCM to your app' (in purple). And as you can see, it doesn't have any version numbers in the URL.
I also encounter a problem with the implementation 'com.google.firebase:firebase-messaging:17.1.0' property.
I'll add in my manifest and gradle files for reference:
AndroidManifest.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.nationscompanies.uordermobile">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<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:fullBackupContent="#xml/backup_descriptor">
<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>
<service
android:name=".MyAndroidFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service
android:name=".MyAndroidFirebaseInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
</application>
</manifest>
build.gradle (Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.nationscompanies.uordermobile"
minSdkVersion 22
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:design: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'
api 'com.google.android.gms:play-services-gcm:15.0.1'
api 'com.google.firebase:firebase-core:16.0.1'
api 'com.google.firebase:firebase-messaging:17.1.0'
}
apply plugin: 'com.google.gms.google-services' // this is the line that gets autofilled when you click on the 'Add FCM to your app' button from Firebase manager
Full error message
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 15.0.1.
And then a giant list of errors:
Change this:
classpath 'com.google.gms:google-services:3.1.1'
into this:
classpath 'com.google.gms:google-services:4.0.2'
to prevent from getting the version conflict error.
Check here for more info:
https://android-developers.googleblog.com/2018/05/announcing-new-sdk-versioning.html
Beginning with version 15 of all Play services and Firebase libraries, each Maven dependency matching com.google.android.gms:play-services-* and com.google.firebase:firebase-* is no longer required to have the same version number in order to work correctly at build time and at run time.
In order to support this change in versioning, the Play services Gradle plugin has been updated to 3.0.0(which is the first version).

Create library of my android project to use another project using android studio 2.1.2

I want to create a library of my own project which include java source code, resources (manifest, layout) file and I'm using Android Studio 2.1.2. Please give me any suggestions how I can create that one and also following one -
1) Want to create .jar library not .AAR.
2) How to add another library or any dependencies in to it, is it possible??
Thanks in advance.
see these tutorials...
How to make a .jar out from an Android Studio project
http://www.technetexperts.com/mobile/export-jar-file-from-android-studio-project/
You just need to change in your app's build.gradle file
search line
apply plugin: 'com.android.application'
and change it to
apply plugin: 'com.android.library'
and most important thing remove line
applicationId "your_package_name"
from the defaultConfig block. because libraries do not have application Id. and then build your project you'll find 'aar' folder inside you build folder.
projectfolder -> build -> output -> aar -> library_file
Edited :
and for Jar file please go through with the below command
Run gradlew makeJar command from your project root.
build.gradle file
build.gradle file apply plugin: 'com.android.library'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:3.0.0'
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
publishNonDefault true
defaultConfig {
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
//Path to your source code
java {
srcDir 'src/main/java'
}
resources {
srcDir 'src/../lib'
}
}
}
// This is important, it will run lint checks but won't abort build
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile files('libs/AdvancedWebView.jar')
compile project(':ShortcutBadger')
compile files('libs/commons-net-3.4.jar')
compile files('libs/ksoap2-android-assembly-3.6.0-jar-with-dependencies.jar')
}
task clearJar(type: Delete) {
delete 'release/' + POM_ARTIFACT_ID + '_' + VERSION_NAME + '.jar'
}
task makeJar(type: Copy) {
from('build/intermediates/bundles/debug/')
into('release/')
include('classes.jar')
rename ('classes.jar', POM_ARTIFACT_ID + '_' + VERSION_NAME + '.jar')
}
makeJar.dependsOn(clearJar, build)
and this is my mainifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="package name">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:label="#string/app_name"
android:supportsRtl="true">
<activity android:name=".SplashScreen"
android:label="#string/app_name"/>
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:label="#string/app_name" >
</activity>
<activity android:name=".NextActivity"
android:label="#string/app_name"/>
</application>
</manifest>

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com

I get this error and I have no idea how to fix it. I have java 7. Thank you in advance. I am new to codding and I dont have any past experience at all, I have done the very basic on paper programing but still. Also what do I have to do to test this application inside the android emulator? Thanks
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.>
com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lightcurb.example" >
<!-- SDK feature -->
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true" />
<application
android:name=".LCExampleApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".activity.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:noHistory="true"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.indooratlas.android.sdk.API_KEY"
android:value="c24c139a-0fd8-4072-b92d-440f1369a413"/>
<meta-data
android:name="com.indooratlas.android.sdk.API_SECRET"
android:value="jU)0v5VVdUGfpE69DUS!zLmqVhA1wiPNymesYonp6XSArIshOSfYKbhJP9v6zIpdl8U9hOhrgQiPWYYjwSWUjgjDlbi44MNu0P52dwglirV0qTAWFfY7sj)ClhXp80i1"/>
</application>
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.lightcurb.example"
minSdkVersion 18
targetSdkVersion 21
versionCode 9
versionName "1.0.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.pro'
}
}
}
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
compile 'com.indooratlas.android:indooratlas-android-sdk:2.0.2-beta#aar'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.radiusnetworks:AndroidIBeaconLibrary:0.7.7#aar'
compile 'com.lightcurb.sdk:LightcurbSDK:1.0.1#aar'
}
repositories{
maven {
url "http://indooratlas-ltd.bintray.com/mvn-public"
}
}

Adding Google Maps Activity gradle build permanent failure

I have simply went through and attempted to add a a Google Map Activity in Android Studio, ie. Right click -> New -> Google -> Google Maps Activity,
Upon completion, the app attempted to build, and subsequently crashed during the build displaying the error:
Gradle 'appname' project refresh failed
Error: exception during working with external systems
Now, the src folder and manifest file have disappeared and any method including the most basic, super.onCreate display "Cannot resolve method"...
When attempting to clean the project it notes:
Error:The markup in the document preceding the root element must be well-formed.
Error:Cannot read packageName from C:\.....\appanme\app\src\main\AndroidManifest.xml
The build.gradle (Project: appname) file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
build.gradle (Module: app) file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.example.appname"
minSdkVersion 14
targetSdkVersion 22
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
// Additional
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.squareup.picasso:picasso:2.5.1'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.android.support:palette-v7:22.2.0'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'com.android.support:appcompat-v7:22.2.0'
}
Why would this happen? How can it be resolved?
UPDATE
AndroidManifest.xml: This code was merged with the manifest, breaking the app
<<<<<<< Original
...
...
</manifest>
=======
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application>
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="#string/google_maps_key"/>
<activity android:name="com.example.socialActions.RestaurantLocationActivity"
android:label="#string/title_activity_restaurant_location">
</activity>
</application>
</manifest>
>>>>>>> Added
The manifest has merge conflicts, review it and remove the <<<< parts and any duplicate / outdated info. Alternately if you're in Android studio you should be able to view file history and revert to an earlier version if you are confused.

Git submodule causing Failure [INSTALL_FAILED_OLDER_SDK] Android sdk 21

I am working on an app and trying to use the new material design, aka sdk version 21.
I had everything working fine, and then wanted to at a fab (floating action button) using this library.
I added this library as a submodule, using
git submodule add https://github.com/shamanland/floating-action-button
while under C:\Users\USER\AndroidStudioProjects\ProjectName
My file structure looks like so
ProjectName
app
floating-action-button
The issue
Before everything was totally fine, I was able to build and run the project.
But, ever since adding this submodule, when trying to run it, I get the error
Failure [INSTALL_FAILED_OLDER_SDK]
So I'm thinking it has to do with the submodule, but I'm not sure how.
app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion '21.0.2'
defaultConfig {
applicationId "com.mayuonline.ribbit"
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:21.+'
compile 'com.android.support:cardview-v7:+'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.android.support:palette-v7:+'
}
app/AndroidManifest.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="resume.kelseyhrubes">
<uses-sdk tools:node="replace" />
<application
android:allowBackup="true"
android:icon="#drawable/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>
f-a-b/build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.2'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
classpath 'org.robolectric:robolectric-gradle-plugin:0.11.0'
}
}
def isSnapshot() {
return VERSION_NAME.contains('SNAPSHOT')
}
def gradleMvnPush = new File(buildDir, 'gradle-mvn-push.gradle')
if (!gradleMvnPush.exists()) {
buildDir.mkdirs()
ant.get(src: GRADLE_MVN_PUSH, dest: gradleMvnPush)
}
setProperty('GRADLE_MVN_PUSH', gradleMvnPush)
subprojects {
group GROUP
version VERSION_NAME
apply plugin: 'android-sdk-manager'
if (name.startsWith('lib')) {
apply plugin: 'com.android.library'
} else {
apply plugin: 'com.android.application'
}
android {
compileSdkVersion COMPILE_SDK_VERSION as int
buildToolsVersion BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion MIN_SDK_VERSION as int
targetSdkVersion TARGET_SDK_VERSION as int
versionCode 1
versionName '1.0'
// workaround for https://code.google.com/p/android/issues/detail?id=52962
buildConfigField 'boolean', 'SNAPSHOT', isSnapshot().toString()
}
lintOptions {
abortOnError false
}
}
repositories {
mavenLocal()
mavenCentral()
}
if (isSnapshot()) {
apply plugin: 'robolectric'
dependencies {
// NOTE workaround for sdkmanager plugin
compile 'com.android.support:support-v4:19.0.1'
androidTestCompile 'junit:junit:4.10'
androidTestCompile 'org.robolectric:robolectric:2.3'
androidTestCompile 'com.squareup:fest-android:1.0.8'
}
}
}
f-a-b/AndroidManifest.xml (probably a clue here, I (tried to) bold the areas that Android Studio has turned red
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=" **http://schemas.android.com/apk/res/android** "
package="com.shamanland.fab.example">
<application
android:name=" **.ExampleApplication** "
android:label="#string/app_name"
**android:icon** ="#drawable/ic_launcher"
**android:theme** ="#style/AppTheme"
**android:allowBackup** ="true"
>
<activity android:name=".ExampleListActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=" **.ExampleDetailsActivity** "/>
</application>
</manifest>
I have a strong suspicion that the submodule was added incorrectly.
Really all I want is to use a fab in my app, if anyone can help me figure out what may be wrong, with adding the submodule, or something with my build.gradle, that would really be appreciated!!
This error is usually caused by deploying an APK built with "compileSdkVersion n" to a device or emulator with an API level less than "n". Is your emulator at the right API level?

Categories

Resources