newrelic / newrelic-capacitor-plugin

Mobile instrumentation plugin for the Capacitor hybrid mobile platform by Ionic
Apache License 2.0
7 stars 10 forks source link

Plugin with id 'newrelic' not found. #71

Closed hughknaus closed 5 months ago

hughknaus commented 5 months ago

Description & Steps to Reproduce

Following these steps: https://github.com/newrelic/newrelic-capacitor-plugin?tab=readme-ov-file#android-setup and those steps seem to have some overlap with some differences from https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile-android/install-configure/install-android-agent-gradle/#manual-install. For one, I'm using Capacitor/Trapeze to build the Android project which works great with modifying build.gradle, app/build.gradle, and AndroidManifest.xml. However, in Android Studio it has the error Plugin with id 'newrelic' not found. So it cannot be built.

I tried adding import com.newrelic.agent.android.NewRelic; to the MainActivity.java and adding an onCreate(...) with NewRelic.withApplicationToken("<GENERATED_TOKEN>").start(this.getApplicationContext()); but issue remains.

Expected Behavior

Expect that since I can build the Ionic/Angular app with Capacitor/Trapeze and generate the Android app that I would be able to build the app from within Android Studio.

Relevant Logs / Console output

Android Studio output:

Build file '/Volumes/Storage/_projects/<MYPROJECTNAME>/android/app/build.gradle' line: 58

A problem occurred evaluating project ':app'.
> Plugin with id 'newrelic' not found.

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.

Your Environment

Apple M2 Max, Sonoma 14.3 Ionic/Angular app building with Capacitor/Trapeze Android Studio Giraffe | 2022.3.1 Patch 1 ** Have not tried building iOS version yet

ndesai-newrelic commented 5 months ago

@hughknaus did you add newrelic classpath in your configuration?

Screenshot 2024-01-30 at 11 59 14 AM
hughknaus commented 5 months ago

@ndesai-newrelic I did have the classpath, but it not have the pointer to the files(...) I'll try adding that.

Here's my what I have in my trapeze yaml (this didn't work by the way), not sure what the path should be:

      - file: build.gradle
        target: 
          buildscript:
            dependencies:
        insert: |
          classpath: "com.newrelic.agent.android:agent-gradle-plugin:7.2.0"
          classpath: files("../node_modules/@newrelic/newrelic-capacitor-plugin/android/src/main/java/com/newrelic/capacitor/plugin"). <--- WHAT PATH SHOULD THIS BE?

      - file: app/build.gradle
        target:
        insert: |
          apply plugin: 'newrelic'

      - file: app/build.gradle
        target:
          dependencies:
        insert: |
          implementation "com.newrelic.agent.android:android-agent:7.2.0"
ndesai-newrelic commented 5 months ago

@hughknaus no need to add files in classpath.

ndesai-newrelic commented 5 months ago

@hughknaus It appears that there might be a bug in the Trapeze installation process where the classpath is not added correctly. In order to address this, you can manually add the classpath while following the installation steps.

hughknaus commented 5 months ago

@ndesai-newrelic I figured it out... silly mistake. I had a colon after classpath so it was showing up like this in my build.gradle file:

classpath: "com.newrelic.agent.android:agent-gradle-plugin:7.2.0"

After removing the colon in my Trapeze file then it worked like magic. Sorry for taking your time.