# Error wrapping native view

**URL:** <https://forums.fusetools.com/t/error-wrapping-native-view/868>\
**Category:** Bug Reports\
**Created:** [February 17, 2017, 12:27pm UTC](https://forums.fusetools.com/t/error-wrapping-native-view/868 "2017-02-17T12:27:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gw\_dev](https://avatars.discourse-cdn.com/v4/letter/g/f1d935/32.png) [@gw\_dev](https://forums.fusetools.com/u/gw_dev)\
**Post date:** [February 17, 2017, 12:27pm UTC](https://forums.fusetools.com/t/error-wrapping-native-view/868/1 "2017-02-17T12:27:13Z")

</div>

```auto
using Uno.Collections;
	using Fuse;
	using Uno;
    using Uno.UX;
    using Uno.Compiler.ExportTargetInterop;
    using Fuse.Controls.Native.Android;
	
	[Require("AndroidManifest.RootElement", "<uses-feature android:name=\"android.hardware.camera\"/>")]
	[Require("AndroidManifest.RootElement", "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>")]
	[Require("Gradle.Dependency.Compile", "me.dm7.barcodescanner:zbar:1.9")]
	[Require("Gradle.Dependency","compile('me.dm7.barcodescanner:zxing:1.9') { exclude module: 'support-v4' }")]
	[Require("Gradle.Repository","mavenCentral()")]
	[extern(Android) ForeignInclude(Language.Java, "android.content.Intent")]
	[extern(Android) ForeignInclude(Language.Java, "android.util.Log")]
	[extern(Android) ForeignInclude(Language.Java, "net.sourceforge.zbar.Symbol")]
	[extern(Android) ForeignInclude(Language.Java, "com.fuse.Activity")]
	[extern(Android) ForeignInclude(Language.Java, "me.dm7.barcodescanner.zbar.ZBarScannerView")]
	extern(Android) public class AndroidQrScanner : LeafView
	{
        
		[UXConstructor]
		public AndroidQrScanner() : base(Create()){
			
		}
	

		[Foreign(Language.Java)]
		static Java.Object Create()
		@{
			ZBarScannerView mScannerView = new ZBarScannerView(Activity.getRootActivity());
			return mScannerView;

		@}
	}

```

so im trying to get leafview to work but when i put this in my custom class that inherits from Control i get

```auto
C:\Users\kingtech\Documents\Fuse\QrScanner\QrScanner.ux(2,1): Error E8001: Data type not found: AndroidQrScanner
QrScanner.unoproj: E0000: Object reference not set to an instance of an object.
C:\Users\kingtech\Documents\Fuse\QrScanner\QrScanner.unoproj(1,1): Error E0000: Object reference not set to an instance of an object.

```

my ux markup

```auto
<QrView ux:Class="QrScanner">
    <AndroidQrScanner />
</QrView>

```

`QrView` is just a basic class inheriting `Control`

```auto
using Uno;
using Uno.UX;
using Fuse.Controls;

    public class QrView : Control
    {
       
    }

```

---

<div class="post-metadata">

**Author:** ![Remi\_Pedersen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/remi_pedersen/32/432_2.png) [@Remi\_Pedersen](https://forums.fusetools.com/u/Remi_Pedersen)\
**Post date:** [February 17, 2017, 12:42pm UTC](https://forums.fusetools.com/t/error-wrapping-native-view/868/2 "2017-02-17T12:42:24Z")

</div>

Hi! It looks like you may have ran into the issue described [here](https://www.fusetools.com/community/forums/bug_reports/fuse_preview_will_fail_to_compile_when_using_forei?page=1) and [here](https://www.fusetools.com/community/forums/permalink/2c38e5c0-1986-4ca4-909a-26e038e23667)

The currently available workaround (as described in those posts) is to add `extern(Android)` on the foreign includes

---

<div class="post-metadata">

**Author:** ![gw\_dev](https://avatars.discourse-cdn.com/v4/letter/g/f1d935/32.png) [@gw\_dev](https://forums.fusetools.com/u/gw_dev)\
**Post date:** [February 17, 2017, 12:57pm UTC](https://forums.fusetools.com/t/error-wrapping-native-view/868/3 "2017-02-17T12:57:37Z")

</div>

thanks for the reply. I already have it like that, or should be added to the Require tags as well?

---

<div class="post-metadata">

**Author:** ![Remi\_Pedersen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/remi_pedersen/32/432_2.png) [@Remi\_Pedersen](https://forums.fusetools.com/u/Remi_Pedersen)\
**Post date:** [February 17, 2017, 1:02pm UTC](https://forums.fusetools.com/t/error-wrapping-native-view/868/4 "2017-02-17T13:02:30Z")

</div>

Oops, sorry, I didn’t notice that. I’ll pass it on internally then.

---

<div class="post-metadata">

**Author:** ![gw\_dev](https://avatars.discourse-cdn.com/v4/letter/g/f1d935/32.png) [@gw\_dev](https://forums.fusetools.com/u/gw_dev)\
**Post date:** [February 17, 2017, 1:04pm UTC](https://forums.fusetools.com/t/error-wrapping-native-view/868/5 "2017-02-17T13:04:53Z")

</div>

thanks much

---

<div class="post-metadata">

**Author:** ![Olle\_Fredriksson](https://avatars.discourse-cdn.com/v4/letter/o/e95f7d/32.png) [@Olle\_Fredriksson](https://forums.fusetools.com/u/Olle_Fredriksson)\
**Post date:** [February 17, 2017, 1:26pm UTC](https://forums.fusetools.com/t/error-wrapping-native-view/868/6 "2017-02-17T13:26:52Z")

</div>

Try adding a mocked version of the class with `extern(!Android)`, for example as follows:

```auto
    extern(!Android) public class AndroidQrScanner
    {
    }

```

See [the docs](https://www.fusetools.com/docs/native-interop/native-ux-components#implementing-code-leafview-code-for-android) where this is mentioned.

---

<div class="post-metadata">

**Author:** ![gw\_dev](https://avatars.discourse-cdn.com/v4/letter/g/f1d935/32.png) [@gw\_dev](https://forums.fusetools.com/u/gw_dev)\
**Post date:** [February 21, 2017, 12:24am UTC](https://forums.fusetools.com/t/error-wrapping-native-view/868/7 "2017-02-21T00:24:08Z")

</div>

> **Olle Fredriksson wrote:**
> 
> Try adding a mocked version of the class with `extern(!Android)`, for example as follows:
> 
> ```auto
> extern(!Android) public class AndroidQrScanner
> {
> }
> 
> ```
> 
> See [the docs](https://www.fusetools.com/docs/native-interop/native-ux-components#implementing-code-leafview-code-for-android) where this is mentioned.

thanks that worked for me. Could you also check out this thread for me [Fuse](https://www.fusetools.com/community/forums/general/cameraview_in_nativeviewhost) ?
