question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compile android error in a clean project

See original GitHub issue

Hi, first of all, thanks for your work on this library! I used in the past and it worked great.

I’m having a compile error on Android in a clean project.

> Task :react-native-udp:generateDebugBuildConfig UP-TO-DATE
> Task :react-native-udp:prepareLintJar UP-TO-DATE
> Task :react-native-udp:generateDebugSources UP-TO-DATE
> Task :react-native-udp:javaPreCompileDebug UP-TO-DATE
> Task :react-native-udp:compileDebugJavaWithJavac UP-TO-DATE
> Task :react-native-udp:processDebugJavaRes NO-SOURCE
> Task :react-native-udp:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE
> Task :app:javaPreCompileDebug

> Task :app:compileDebugJavaWithJavac FAILED
/rnproject/android/app/src/main/java/com/rnproject/MainActivity.java:3: error: cannot find symbol
import com.facebook.react.ReactActivity;
                         ^
  symbol:   class ReactActivity
  location: package com.facebook.react
/rnproject/android/app/src/main/java/com/rnproject/MainActivity.java:5: error: cannot find symbol
public class MainActivity extends ReactActivity {
                                  ^
  symbol: class ReactActivity
/rnproject/android/app/src/main/java/com/rnproject/MainApplication.java:5: error: cannot find symbol
import com.facebook.react.ReactApplication;

I know that it seems that error is related to my MainApplication but this only happening if I activate the react-native-udp module.

react-native-cli: 2.0.1 react-native: 0.58.3

How to reproduce it

  1. react-native init newproject
  2. cd newproject
  3. yarn add react-native-udp
  4. react-native link react-native-udp
  5. react-native run-android

MainApplication.java

package com.rnproject;

import android.app.Application;

import com.facebook.react.ReactApplication;
import com.tradle.react.UdpSocketsModule;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;

import java.util.Arrays;
import java.util.List;

public class MainApplication extends Application implements ReactApplication {

  private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
    @Override
    public boolean getUseDeveloperSupport() {
      return BuildConfig.DEBUG;
    }

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
            new UdpSocketsModule()
      );
    }

    @Override
    protected String getJSMainModuleName() {
      return "index";
    }
  };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    SoLoader.init(this, /* native exopackage */ false);
  }
}

build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "28.0.2"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 27
        supportLibVersion = "28.0.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}


task wrapper(type: Wrapper) {
    gradleVersion = '4.7'
    distributionUrl = distributionUrl.replace("bin", "all")
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mvayngribcommented, Feb 1, 2019

@tinchoz49 cool, published as 2.4.0

I want to ask you about react-native-udp + bittorrent-dht, do you think that it’s ok to open a new issue to talk about it?

sure, open away

1reaction
tinchoz49commented, Feb 1, 2019

fixed by the release v2.4.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Errors in Android Studio unless I build/clean each time
Try following ways in order of listing: Select Make Project from Build menu. Go to File menu and select Invalidate Cache/restart .
Read more >
Different Ways to fix "Execution failed for task ':app:clean ...
Method 1 · Close Android Studio. Then try to manually delete the build files and open Android Studio again. · We need to...
Read more >
Command 'clean android project' failed with code: 1 ... - GitHub
Trying to use: npx react-native-clean-project Get the following error:
Read more >
Optimize your build speed | Android Developers
Optimize your build configuration by taking a few steps that immediately benefit most Android Studio projects. Profile your build to identify and diagnose...
Read more >
Infographic: 11 Most Common Android Errors and How to Fix ...
If you're encountering this error, then try cleaning (Clean > Build Project) and rebuilding your project (Build > Rebuild Project). If this doesn't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found