I am an Android newbie,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exaggmple.sadgh"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
</application>
</manifest>
thıs ıs my manıfest.xml, but ı stıll get the error lıke no launcher :( , please help. thanks!
Related
I am getting the following exception when trying to take a photo: "Unable to get file location. This most likely means that the file provider information is not set in your Android Manifest file. Please check documentation on how to set this up in your project."
<provider android:name="androidx.core.content.FileProvider" android:authorities="MYPACKAGENAME.fileprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="#xml/file_paths"></meta-data>
</provider>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
I have a file under Resources/xml called file_paths.xml, it's BuildAction is set to AndroidResource, and looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-files-path name="my_images" path="Pictures" />
<external-files-path name="my_movies" path="Movies" />
</paths>
I am using the Xam.Plugin.Media plugin (from James Montemagno), and when I call TakePhotoAsync, I get the exception
await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
{
Directory = "MyFolder",
SaveToAlbum = true,
CompressionQuality = 40,
CustomPhotoSize = 35,
PhotoSize = PhotoSize.Medium,
MaxWidthHeight = 1000,
});
I'm not sure if this is the solution but when I've used this library in the past I've used a different provider name. So instead of
<provider android:name="androidx.core.content.FileProvider"...
I used
<provider android:name="android.support.v4.content.FileProvider" ...
I had down a demo which used the code you had provided and the same nuget package. I also met the error. I tried many ways and when I set "android:authorities="${applicationId}.fileprovider" it worked well. So you can have a try.
The Android Manifest file:
<application android:label="App15.Android" android:theme="#style/MainTheme">
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="#xml/file_paths"></meta-data>
</provider>
</application>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
I have scenario where I have to download apk in background and install it without prompting any dialog to user. However when I try to install it using below code File
string mypath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).AbsolutePath;
var filePath = Path.Combine(mypath, fileName);
if (File.Exists(filePath))
{
string extention = Android.Webkit.MimeTypeMap.GetFileExtensionFromUrl(Android.Net.Uri.FromFile(new Java.IO.File(filePath)).ToString());
string mimeType = Android.Webkit.MimeTypeMap.Singleton.GetMimeTypeFromExtension(extention);
Context context = Android.App.Application.Context;
Android.Net.Uri fileUri = FileProvider.GetUriForFile(context, context.PackageName + ".provider", new Java.IO.File(filePath));
Intent intent = new Intent(Intent.ActionView);
intent.SetDataAndType(fileUri, mimeType);
intent.AddFlags(ActivityFlags.NewTask);
intent.AddFlags(ActivityFlags.GrantReadUriPermission);
context.StartActivity(intent);
}
and below code for xml file
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_file" path="." />
</paths>
and below code for AndroidManifest.xml file
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.fileprovider">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.permission.INSTALL_LOCATION_PROVIDER" />
<uses-permission android:name="android.permission.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:label="Fileprovider.Android" android:theme="#style/MainTheme">
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="#xml/file_paths"/>
</provider>
</application>
</manifest>
but when click button to open .apk file view below error
enter image description here
You cannot install APK without the prompt on Android. Actually I don't think you can do the similar thing on any modern operating system.
I have an instant app, and its working nice, but if I add this line to my base/build.gradle then I cant run my app/installed, note that I can run it with a url.
api 'com.google.firebase:firebase-core:16.0.1'
The error is "Default activity not found".
Removing the compile firebase, voilá the activity is found.
Using implementation instead of api the app runs nice, but firebase says "installation unsucessful" but using api and running it as a instant app firebase says "successful"
My build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.example.android.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode rootProject.ext.versionCodeInstalled
versionName rootProject.ext.versionNameInstalled
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation project(':feature')
implementation project(':base')
}
Manifest app:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.app" />
Manifest base:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<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">
<meta-data
android:name="aia-compat-api-min-version"
android:value="1" />
</application>
</manifest>
Any idea?
This solution worked for me:
In the base/manifest
<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">
<meta-data
android:name="aia-compat-api-min-version"
android:value="1" />
<provider
android:name="com.google.firebase.provider.FirebaseInitProvider"
android:authorities="com.menuymenu.android.app.firebaseinitprovider"
android:exported="false"
tools:node="merge"/>
</application>
This has been the biggest headache for me. I've been following the tutorial at
https://developers.google.com/maps/documentation/android-api/start?hl=en
but I always get a
android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class fragment
ONLY on api 23. This is the most confusing part. Other APIs over 18 work fine.
I believe I've covered all the basic components,
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<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=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
My google play version is up to date.(8487000)
I've tried placing the map fragment everywhere. Nothing seems to work.
activity_maps.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/maps"
class ="com.google.android.gms.maps.SupportMapFragment" />
MapsActivity:
package com.example.michael.myapplication;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
public class MapsActivity extends android.support.v4.app.FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.maps);
mapFragment.getMapAsync(this);
}
#Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
// Add a marker in Sydney, Australia, and move the camera.
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
For anyone stumbling on this:
Reinstall your emulator. Seriously. That fixed it for me.
If you are testing on emulator, try removing and creating AVD again. I was also facing that issue and that fixed for me.
I am following the steps in google but can't see my map in fragment. bellow is the code. if guys please help me?
I already added google-play-services_lib with my project. testing in real device. using Google APIs
Mainfest: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mymaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="12"
android:targetSdkVersion="17" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<permission
android:name="com.example.mymap.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="com.example.mymap.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.mymaps.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="MY KEY" />
<uses-library
android:name="com.google.android.maps"
android:required="true" />
</application>
</manifest>
UI XML:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
<fragment
android:id="#+id/the_map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment"
/>
</RelativeLayout>
MainActivity:
package com.example.mymaps;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
setContentView(R.layout.activity_main);
} catch (Exception e) {
System.out.print(e);
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Put these lines on the AndroidManifest.xml file after the meta-data tag::
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
Google has made it mandatory for android phones to have the google play services installed in order to use the map. So the tag checks for google play services is installed on the phone or not. If no, then it automatically redirects the user to google play site to get the required software installed..
If the problem still exists, then use this tutorial by Ravi Tamada and do not forget to add the lines mentioned in this answer.
http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/
dec variable as global private GoogleMap googleMap;
extends FragmentActivity not Activity
after setContentView add this code
FragmentManager fragmentManager = getSupportFragmentManager();
SupportMapFragment mapFragment = (SupportMapFragment) fragmentManager
.findFragmentById(R.id.map);
googleMap = mapFragment.getMap();
googleMap.getUiSettings().setCompassEnabled(true);
googleMap.getUiSettings().setZoomControlsEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
googleMap.setMyLocationEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
googleMap.getUiSettings().setRotateGesturesEnabled(true);
in xml
<fragment
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment" />
if you generate the googleMap api key with currect pakage name this will work