Can not find symbol Finder - butterknife

I set up ButterKnife into Android Studio.
project build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
app build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
...
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
...
compile 'com.jakewharton:butterknife:8.4.0'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
And I have this:
Error:(6, 28) error: cannot find symbol class Finder
in
..\DetailActivity$$ViewBinder.java
I am trying:
public class DetailActivity extends AppCompatActivity {
#BindView(R.id.title_textview) TextView titleTextView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
ButterKnife.bind(this);
...
titleTextView.setText(movie.getTitle());

Related

Nancy.Json.JsonSettings in Nancy v2

I'm upgrading my project from Nancy 1.4.5 -> 2.0
And I have errors:
public class AppBootstrapper : AutofacNancyBootstrapper
{
private readonly ILifetimeScope _scope;
public AppBootstrapper(ILifetimeScope scope)
{
_scope = scope;
}
protected override ILifetimeScope GetApplicationContainer()
{
return _scope;
}
protected override void ApplicationStartup(ILifetimeScope container, IPipelines pipelines)
{
JsonSettings.MaxJsonLength = int.MaxValue;
JsonSettings.RetainCasing = true;
base.ApplicationStartup(container, pipelines);
}
}
}
Error CS0103 The name 'JsonSettings' does not exist in the current context
How can I resolve this issue?
I added method to AppBootstrapper class:
public class AppBootstrapper : DefaultNancyBootstrapper
{
public override void Configure(INancyEnvironment environment)
{
environment.Json(retainCasing: true);
}
... other methods
}
And added maxJsonLength to web.config:
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483647"/>
</webServices>
</scripting>
</system.web.extensions>

'com.android.support:support-v4' dependency issue

I need to integrate react-native-beacons-manager to my react-native project on PhpStorm, so i installed the library using the command "yarn install react-native-beacons-manager" and then link it to my project using the command "react-native link react-native-beacons-manager". But now, when i try running my build, the following message is shown:
> Android dependency 'com.android.support:support-v4' has different version for the compile (21.0.3) and runtime (26.1.0) classpath. You should manually set the same version via DependencyResolution
app\build.gradle:
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.mapapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation project(':react-native-beacons-manager')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-maps')
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
settings.gradle:
rootProject.name = 'mapapp'
include ':react-native-beacons-manager'
project(':react-native-beacons-manager').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-beacons-manager/android')
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
include ':app'
MainApplication.java:
package com.mapapp;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.mackentoch.beaconsandroid.BeaconsAndroidPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.airbnb.android.react.maps.MapsPackage;
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 BeaconsAndroidPackage(),
new MapsPackage()
);
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
android\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")
}
My Android version is 8.1.0.
Edit: When i applied the code from abhinandan sharma, the following message was shown:
> Task :app:compileDebugJavaWithJavac FAILED
C:\Users\Vex\PhpstormProjects\mapapp\android\app\src\main\java\com\mapapp\MainActivity.java:3: error
: cannot find symbol
import com.facebook.react.ReactActivity;
^
symbol: class ReactActivity
location: package com.facebook.react
C:\Users\Vex\PhpstormProjects\mapapp\android\app\src\main\java\com\mapapp\MainActivity.java:5: error
: cannot find symbol
public class MainActivity extends ReactActivity {
^
symbol: class ReactActivity
C:\Users\Vex\PhpstormProjects\mapapp\android\app\src\main\java\com\mapapp\MainApplication.java:5: er
ror: cannot find symbol
import com.facebook.react.ReactApplication;
^
symbol: class ReactApplication
location: package com.facebook.react
C:\Users\Vex\PhpstormProjects\mapapp\android\app\src\main\java\com\mapapp\MainApplication.java:7: er
ror: cannot find symbol
import com.facebook.react.ReactNativeHost;
^
symbol: class ReactNativeHost
location: package com.facebook.react
C:\Users\Vex\PhpstormProjects\mapapp\android\app\src\main\java\com\mapapp\MainApplication.java:17: e
rror: cannot find symbol
public class MainApplication extends Application implements ReactApplication {
^
symbol: class ReactApplication
C:\Users\Vex\PhpstormProjects\mapapp\android\app\src\main\java\com\mapapp\MainApplication.java:19: e
rror: cannot find symbol
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
^
symbol: class ReactNativeHost
location: class MainApplication
C:\Users\Vex\PhpstormProjects\mapapp\android\app\src\main\java\com\mapapp\MainApplication.java:41: e
rror: cannot find symbol
public ReactNativeHost getReactNativeHost() {
^
symbol: class ReactNativeHost
location: class MainApplication
C:\Users\Vex\PhpstormProjects\mapapp\android\app\src\main\java\com\mapapp\MainActivity.java:11: erro
r: method does not override or implement a method from a supertype
#Override
^
C:\Users\Vex\PhpstormProjects\mapapp\android\app\src\main\java\com\mapapp\MainApplication.java:19: e
rror: cannot find symbol
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
^
symbol: class ReactNativeHost
location: class MainApplication
C:\Users\Vex\PhpstormProjects\mapapp\android\app\src\main\java\com\mapapp\MainApplication.java:40: e
rror: method does not override or implement a method from a supertype
#Override
^
10 errors
Add this in your build.gradle file
android -> build.gradle
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "26.1.0"
}
}
}
}
Hope it Helps !

java.lang.ClassCastException: fi.rogerstudio.possis.MainApplication cannot be cast to com.facebook.react.ReactApplication

I am getting this error when receiving push notification only when the app is open, foreground mode!
Does anyone had this issue before using the Firebase push notification and react-native-fcm?
COde:
showLocalNotification(notif) {
FCM.presentLocalNotification({
title: notif.title,
body: notif.body,
priority: "high",
click_action: notif.click_action,
show_in_foreground: true,
local: true
});
}
Mainapplication.java:
public class MainApplication extends MultiDexApplication {
// Needed for `react-native link`
public List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
// Add your own packages here!
// TODO: add cool native modules
// new MainReactPackage(),
new RNBackgroundGeolocation(),
// Needed for `react-native link`
new FIRMessagingPackage(),
//new RNBackgroundGeolocation(),
//new RNFirebasePackage(),
new VectorIconsPackage()
//new RNFirebaseMessagingPackage()
);
}
}
Full Error I am getting:
java.lang.ClassCastException: fi.rogerstudio.possis.MainApplication cannot be cast to com.facebook.react.ReactApplication
at com.evollu.react.fcm.MessagingService$1.run(MessagingService.java:41)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
For someone who may be coming to this 3.5 years after the fact, the solution is to make sure your main application extends ReactApplication,
public class MainApplication extends MultiDexApplication, ReactApplication
and then implement getReactNativeHost like this:
public class MainApplication extends MultiDexApplication {
...
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
#Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
#Override
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}
#Override
protected String getJSMainModuleName() {
return "index";
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
...
}

Ejb3 -Accessing Local Enterprise Beans Using the No-Interface View

I'm trying to learn EJB3,
I created an EJB project with just a bean class:
package com;
import javax.ejb.Local;
import javax.ejb.Stateless;
#Stateless
#LocalBean
public class MyBean {
public MyBean() {
// TODO Auto-generated constructor stub
}
public String getMessage(){
return "Hello";
};
}
I deployed this project on Jboss 6 , then i create a Java project (adding in the build path the ejbProject above and Jboss-client.jar to make RMI calls).
for testing , this is the class i created:
import javax.ejb.EJB;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.MyBean;
public class LanceProgram {
// #EJB
//public static MyBean mybean;
public static void main(String[] args) {
Context ctx;
try {
ctx = new InitialContext();
MyBean exampleBean = (MyBean) ctx.lookup("MyBean");
System.out.println(exampleBean.getMessage());
} catch (NamingException e) {
e.printStackTrace();
}
}
}
Normally, when running this, i should have a reference to MyBean,but it's null and i have this error message (using JNDI lookup):
Exception in thread "main" java.lang.ClassCastException: org.jnp.interfaces.NamingContext cannot be cast to com.MyBean
at LanceProgram.main(LanceProgram.java:17)
While with an EJB injection i have a NullPointerException !
this i my jndi.properties file specifications:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=localhost:1099
java.naming.factory.url.pkgs=org.jboss.ejb.client.naming
I'm trying to make a call to a bean which doesn't implements an interface.
Thanks for helping

module dependencies in prism wpf

i am trying to code something similar to the project 'Modularity with unity'.
i built 2 modules: Module A (loaded via code) and Module D (loaded from directory).
both are loaded successfully.
but when i try to set dependency it's not working.
i can't really figure out where the dependency is mentioned in this project.
(i set the dependency as attribute in ModuleA class, moduleD is copied after build)
this is my implementation:
Bootstrapper.cs
protected override IModuleCatalog CreateModuleCatalog()
{
return new AggregateModuleCatalog();
}
protected override void ConfigureModuleCatalog()
{
base.ConfigureModuleCatalog();
Type moduleAType = typeof(ModuleAModule);
ModuleCatalog.AddModule(new ModuleInfo()
{
ModuleName = ModuleNames.ModuleA,
ModuleType = moduleAType.AssemblyQualifiedName
});
DirectoryModuleCatalog directoryCatalog = new DirectoryModuleCatalog() { ModulePath = #".\Modules" };
((AggregateModuleCatalog)ModuleCatalog).AddCatalog(directoryCatalog);
}
protected override void ConfigureContainer()
{
base.ConfigureContainer();
this.RegisterTypeIfMissing(typeof(IModuleTracker), typeof(ModuleTracker), true);
}
ModuleA.cs
[Module(ModuleName = ModuleNames.ModuleA)]
[ModuleDependency(ModuleNames.ModuleD)]
public class ModuleAModule : IModule
{
private ILoggerFacade _logger;
private IModuleTracker _moduleTracker;
public ModuleAModule(ILoggerFacade logger, IModuleTracker moduleTracker)
{
_logger = logger;
_moduleTracker = moduleTracker;
_moduleTracker.ModuleConstructed("ModuleA");
}
public void Initialize()
{
_logger.Log("ModuleA demonstrates logging during Initialize().", Category.Info, Priority.Medium);
_moduleTracker.ModuleInitialized("ModuleA");
}
}
ModuleD.cs
[Module(ModuleName = ModuleNames.ModuleD)]
public class ModuleDModule : IModule
{
private ILoggerFacade _logger;
private IModuleTracker _moduleTracker;
public ModuleDModule(ILoggerFacade logger, IModuleTracker moduleTracker)
{
_logger = logger;
_moduleTracker = moduleTracker;
_moduleTracker.ModuleConstructed("ModuleD");
}
public void Initialize()
{
_moduleTracker.ModuleInitialized("ModuleD");
}
}
perhaps that has something to do with the order in which your modules get loaded? As far as I see Module A gets loaded before ModuleD to which is has a dependency.
Don't know if that does help you but that was my first thought..
Which error message do you get?

Resources