Console Log
/Users/heermi/Flutter/Secure Home Project/Secure Home Repo/secure-home/android/app/src/main/java/com/k8sllc/securehome/MainActivity.java:27: error: cannot find symbol
GeneratedPluginRegistrant.registerWith(FlutterEngine);
symbol: variable FlutterEngine
location: class MainActivity
/Users/heermi/Flutter/Secure Home Project/Secure Home Repo/secure-home/android/app/src/main/java/com/k8sllc/securehome/MainActivity.java:28: error: cannot find symbol
methodChannel = new MethodChannel(getFlutterView(),CHANNEL);
symbol: method getFlutterView()
location: class MainActivity
/Users/heermi/Flutter/Secure Home Project/Secure Home Repo/secure-home/android/app/src/main/java/com/k8sllc/securehome/MainActivity.java:34: error: cannot find symbol
new MethodChannel(getFlutterView(), CHANNEL).setMethodCallHandler(
symbol: method getFlutterView()
location: class MainActivity
Note: /Users/heermi/Flutter/Secure Home Project/Secure Home Repo/secure-home/android/app/src/main/java/com/k8sllc/securehome/FireBaseMessagingService.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.k8sllc.securehome">
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<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" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.VIBRATE" />
<application
tools:replace="android:label"
android:name=".BaseApp"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true"
android:label="Lok">
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="true" />
</activity>
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="test_key” />
<meta-data
android:name="com.transistorsoft.locationmanager.license"
android:value="test_key" />
<meta-data
android:name="com.transistorsoft.locationmanager.ENCRYPTION_PASSWORD"
android:value="test_pass” />
<service
android:name="com.transistorsoft.locationmanager.service.TrackingService"
android:foregroundServiceType="location"/>
<service
android:name="com.transistorsoft.locationmanager.service.LocationRequestService"
android:foregroundServiceType="location"/>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
<!-- Add this content for push notification -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_channel_id"
android:value="Lok" />
<service android:name=".FireBaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name=".FireBaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
</application>
MainActivity.java
package com.k8sllc.securehome;
import android.annotation.TargetApi;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import io.flutter.embedding.android.FlutterActivity;
import org.json.JSONException;
import org.json.JSONObject;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugins.GeneratedPluginRegistrant;
import static android.content.ContentValues.TAG;
public class MainActivity extends FlutterActivity {
public static MethodChannel methodChannel;
private String CHANNEL = "com.k8sllc.securedhome/platform_channel";
private static final String TAG1 = "MainActivity";
Intent intent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(FlutterEngine);
methodChannel = new MethodChannel(getFlutterView(),CHANNEL);
Log.e(TAG1, "onCreate: " );
//Intent which we are passing in android will be used here to make json and then send it flutter application. Okay?yes
intent = getIntent();
new MethodChannel(getFlutterView(), CHANNEL).setMethodCallHandler(
(call, result) -> {
if (call.method.equals("getIntent")) {
if (intent != null) {
JSONObject userDetails = new JSONObject();
try {
userDetails.put("data", intent.getStringExtra("data"));
} catch (JSONException e) {
Log.v(TAG, "onError: " + e);
}
result.success(userDetails.toString());
} else {
android.util.Log.e(TAG, "onCreate: No Intent" );
result.success("false");
}
} else {
result.notImplemented();
}
}
);
}
@Override
protected void onStart() {
super.onStart();
Log.e(TAG1, "onStart: "+getIntent().hasExtra("type") );
}
@Override
protected void onResume() {
super.onResume();
Log.e(TAG1, "onResume: "+getIntent().hasExtra("type") );
}
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (intent != null) {
JSONObject userDetails = new JSONObject();
try {
userDetails.put("data", intent.getStringExtra("data"));
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
MainActivity.methodChannel.invokeMethod("notification", userDetails.toString());
}
});
} catch (JSONException e) {
Log.v(TAG, "onError: " + e);
}
}
}
private void cancelAllNotifications() {
// NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationManager notificationManager = (NotificationManager) getApplication().getSystemService( Context.NOTIFICATION_SERVICE );
notificationManager.cancelAll();
}
}
Flutter doctor summary
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.17.4, on Mac OS X 10.15.5 19F101, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.48.0)
[✓] Connected device (1 available)
• No issues found!
Here I have attached all that I did. Could anyone please help me with this? Here I have attached console log and AndroidManifest.XML snippet to understand it better. I have added MainActivity.java file snippet for the push notification idea what I have done.